Dim Table1 As New DataTable
Dim AdTable1 As New SqlDataAdapter("SELECT * from Table1", Me.ConSQL)
Table1.Clear()
AdTable1.Fill(Table1)
Table1.Rows.Add("Table2_Colums1_To_Add")
Table1.Rows.Add("Table2_Colums2_To_Add")
Dim I, IdT1, Qry
For I = 0 To Table1.Rows.Count - 1
IdT1 = Table1.Rows(I).Item("Id")
Qry = "Select * from Table2 where IdT2='" & IdT1 & "'"
Dim Table2 As New DataTable
Dim AdTable2 As New SqlDataAdapter(Qry, Me.ConSQL)
Table2.Clear()
AdTable2.Fill(Table2)
If Table2.Rows.Count > 0 Then
Table1.Rows(I).BeginEdit()
Table1.Rows(I).Item("Table2_Colums1") = Table2.Rows(0).Item("Table2_Colums1")
Table1.Rows(I).Item("Table2_Colums2") = Table2.Rows(0).Item("Table2_Colums2")
Table1.Rows(I).AcceptChanges()
End If
Next
Me.Datagridview1.Datasource=Table1
Me.datagridview1.refresh
|