CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    23

    how to show data in gridview from two tables

    Dear Seniours,
    Please guide me how can i show data in a single gridview from two tables in windows forms.

  2. #2
    Join Date
    May 2010
    Posts
    9

    Re: how to show data in gridview from two tables

    Just to clarify, are the two tables linked using Primary / Foreign keys or are they completely unrelated?

  3. #3
    Join Date
    Nov 2008
    Posts
    23

    Re: how to show data in gridview from two tables

    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();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured