Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
plz help me i m begnner ..need help...how to select different columns from differnt tables and values of these columns show in datagridview collectively ......through query..waiting for reply
Posted

See this[^] thread.
 
Share this answer
 
See this beginner guide to SQL[^], it can help you out.
 
Share this answer
 
You can use Query with JOINS for this purpose. Sample code is here below:

string constr = "Data Source=.\\SQLEXPRESS; database=Library; Persist Security Info=False; Integrated Security=true;";
      using (SqlConnection con = new SqlConnection(constr))
      {
          cmd1 = con.CreateCommand();
          cmd1 = new SqlCommand("Select B.BookName, P.Publication from Books B Inner Join Publication P on B.PublicationCode = P.PublicationCode");
                cmd1.Connection = con;

                ds = new DataSet();
                adp = new SqlDataAdapter(cmd1);
                adp.Fill(ds, "Books");

                dataGridView1.DataSource = ds.Tables["Books"].DefaultView;
            }




Hope this will be useful for you.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900