Click here to Skip to main content
Sign Up to vote bad
good
See more: C#database
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
Edited 26-Nov-12 21:07pm

Comments
Sergey Alexandrovich Kryukov - 27-Nov-12 2:44am
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... --SA
niko_tells - 27-Nov-12 2:53am
ok im sorry, gonna update it

1 solution

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();
da.fill(dt);
 
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

  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 488
1 Ron Beyer 306
2 Tadit Dash 253
3 samadhan_kshirsagar 229
4 OriginalGriff 198
0 Sergey Alexandrovich Kryukov 7,041
1 Prasad_Kulkarni 3,815
2 OriginalGriff 3,557
3 _Amy 3,372
4 CPallini 3,034


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