0

Using Visual Studio 2012

I have a sql database with a table(name of table: gTable). I have "gTabletableAdapter". I have wrote some query in gTabletableAdapter and now I can use them from Form1.cs like below.

greetingTableTableAdapter.SelectQuery(Int32.Parse(textBox1.Text));

this query returns an object: object .I want to use selected rows. How can I do that. I don't want to use sqlConnection. I want to use the object which my tableAdapter returned. I have searched a lot and found nothing. thanks.

Meysam Valueian
  • 661
  • 1
  • 5
  • 21
  • If that returns a result set, as opposed to a scalar value, the "object" should be a strongly typed DataTable. Did you debug and inspect the returned object to see its properties? – Crowcoder Jan 02 '15 at 15:08
  • when I use `object o=greetingTableTableAdapter.selectSingleValueQuery(textBox13.Text); richTextBox1.Text= o.ToString();` it ruturns me the id of firstSelected row. I don't know what is `object' and how I can use it :'( – Meysam Valueian Jan 02 '15 at 15:16
  • Sounds like it is returning a scalar value and not a result set. What is the sql statement of the SelectQuery? – Crowcoder Jan 02 '15 at 15:31
  • the code in `selectQuery` is: `SELECT * FROM gTable WHERE question LIKE @q` – Meysam Valueian Jan 02 '15 at 15:41
  • Please show the code for the SelectQuery method. – Jurgen Camilleri Jan 02 '15 at 15:47
  • I have defined this function in tableAdapter and I had wrote the code in comment number 4! – Meysam Valueian Jan 02 '15 at 16:00
  • "selectSingleValueQuery" is not the same as selectQuery. The former implies a scalar value is returned. We can't see enough of your code to know what you are trying to do, you are getting mixed up with what you want to call. – Crowcoder Jan 02 '15 at 16:16
  • @Crowcoder : Oh. Yes . You are right. `selectSingleValueQuery` means `SelectQuery` – Meysam Valueian Jan 02 '15 at 16:20
  • It's simple. I have defined some queries in tableAdapter environment and now I want to use them in my main form. I want to fetch some info from my table and use them. how can I fetch data from my table using tableAdapter queries??? – Meysam Valueian Jan 02 '15 at 16:38
  • You must use the correct query for the data you want. The one you are using returns a single id value but you are expecting a result set of rows. I can't specifically tell you what to do because I can't see your project but you must use or create a query that returns the rows you want. – Crowcoder Jan 02 '15 at 16:46

0 Answers0