Udhay
Udhay

Reputation: 71

How to display two tables from a Dataset in a DataGridView

I have a Dataset with 2 different tables. What I have to do is to display those tables in a DataGridView. What I have done with a reference is given below.

    sqlCmd.CommandText = "AutomateKDB"
    sqlCmd.CommandType = CommandType.StoredProcedure
    sqlCmd.Connection = Connection
    sqlCmd.ExecuteNonQuery()
    sqlDaK1 = New SqlDataAdapter(sqlCmd)
    sqlDaK1.Fill(Kds, "KA")

    sqlCmdeA.CommandText = "AutomateeAudIT_KAData"
    sqlCmdeA.CommandType = CommandType.StoredProcedure
    sqlCmdeA.Connection = Connection1
    sqlCmdeA.ExecuteNonQuery()
    sqlDaeK1 = New SqlDataAdapter(sqlCmd)
    sqlDaeK1.Fill(Kds, "eK")

    GridKnowledge.DataSource = Kds

But this is not working. Please help me with this.

Thanks In Advance.,

Upvotes: 0

Views: 7992

Answers (3)

user2605952
user2605952

Reputation: 11

You make view of two tables .

  1. open Server Explore
  2. Click View
  3. Adding Table
  4. Select Field

Note same field in tables, select one of them

Upvotes: 1

KV Prajapati
KV Prajapati

Reputation: 94625

You can use two different DataGridView or nest them. Take a look at MSDN article - Nested Grids for Hierarchical Data and Code Project article - DataGridView with hierarchical data binding

Upvotes: 1

jmoreno
jmoreno

Reputation: 13551

Here's a solution that was posted to the msdn forums sometime ago.

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/0a63a483-5b15-40d6-afb4-8add6b4f244f

Alternatively, you might consider mixing winform and wpf, where I believe this is relatively easy...

Upvotes: 0

Related Questions