Click here to Skip to main content
13,055,047 members (74,244 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi guys,

im for first time using a database in c#.
I would like to know how do i read, compare values
in different data tables.

And most important, how do i get all values of a row from a datatable.
I have 4 DataTables. In ech table are some rows. Now i get that
rows into a form. By doing this, i have created relations to the tables from
the dataset.

After that, i opened the dataset. I have seen that it is possible on "right-click"
to add a method for searching/output values from tables, querry.

Now i started the querry helper, by clicking my table and set the method settings,
for searching my value. Afterwards i opened my form and set the Table and the
table adapter. I searched that table with "foreach". Everything works fine.

But, now i need to search another table, and by doing this by the same proces
as explained it doesnt work, it tells me on creating the query, the
shema is another as the main query.

Let me know if you need a more precise explaination.

Thank you

Greets Niko
Posted 26-Nov-12 20:23pm
Updated 26-Nov-12 21:07pm
I don't need any explanations, but probably you do, if you want any answers... :-)
"It seems that im not doing it correctly" is not informative at all; isn't it obvious? You are the only one who knows your problem, so this is you who needs to judge what is sufficient information. Use some logic...
niko_tells 27-Nov-12 2:53am
ok im sorry, gonna update it

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

using System.Data;
using System.Data.SqlClient;
SqlConnection con=new SqlConnection("Connection string of your database");
string query="select * from users";
SqlDataAdapter da=new SqlDataAdapter(query, con);
DataTable dt=new DataaTable();
foreach(DataRow dr in dt.Rows)
   if(dr["FirstName"].ToString()== fnameTxtBox.Text)
       Label.Text = "Welcome "+fnameTxtBox.Text;
}   // you can loop through all the records (i.e Rows) using this loop, modify the code as per requirements

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100