Sub LoadData()
If oCn.State = ConnectionState.Closed Then
oCn.Open()
End If
Dim cmd As New SqlClient.SqlCommand("SELECT T_Cat.CategoryID, T_Cat.Cat_Name, TN.estbProducerID, TN.NewProducer FROM T_Cat LEFT OUTER JOIN TN ON T_Cat.CategoryID = TN.CategoryID", oCn)
Dim da As New SqlClient.SqlDataAdapter(cmd)
Dim ds As New DataSet("bpl")
Dim i As Integer = 0
Me.DataGridView1.Rows.Clear()
Try
da.Fill(ds, "bpl")
If ds.Tables(0).Rows.Count > 0 Then
While (i <> ds.Tables(0).Rows.Count)
Me.DataGridView1.Rows.Add()
Me.DataGridView1.Item(0, i).Value = i + 1
Me.DataGridView1.Item(1, i).Value = ds.Tables(0).Rows(i).Item(0).ToString
Me.DataGridView1.Item(2, i).Value = ds.Tables(0).Rows(i).Item(1).ToString
Me.DataGridView1.Item(3, i).Value = ds.Tables(0).Rows(i).Item(2).ToString
Me.DataGridView1.Item(4, i).Value = ds.Tables(0).Rows(i).Item(3).ToString
Me.DataGridView1.Item(5, i).Value = Format(Date.Today, "dd-MMM-yyyy")
i = i + 1
End While
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub