Dear Seniours,
Please guide me how can i show data in a single gridview from two tables in windows forms.
Printable View
Dear Seniours,
Please guide me how can i show data in a single gridview from two tables in windows forms.
Just to clarify, are the two tables linked using Primary / Foreign keys or are they completely unrelated?
Yes Sir both tables are liked primary-foreign key.
i am trying this code to show my gridview after join operation but i am unable to write correct code please help me out.
SqlConnection con = new SqlConnection("Data Source=TSARavi\\SQL2005,1435;Initial Catalog=TestDB;User ID=testdb;Password=testdb1");
con.Open();
string query = "SELECT Users.UserName, Users.UserPassword, UsersDetails.fullName,UsersDetails.qualification,UsersDetails.Address FROM Users INNER JOIN UsersDetails ON Users.UserID =UsersDetails.UserID ORDER BY UsersDetails.fullName";
SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery();
con.Close();