Data from Customers will be displayed on Customer Form by means of a Data Grid control named Data Grid1 The following code segment is used to fill Data Grid1

Private Sub FillDataGrid()

Dim oConn As New SqlConnection(MyConString) Dim oDA As New SqlDataAdapter( _

"SELECT CustomerlD, CompanyName, ContactName, " & _ "Phone FROM Customers", oConn) Dim oDS As New DataSet()

oDA.MissingSchemaAction = MissingSchemaAction.AddWithKey oDA.Fill(oDS, "Customers")

Dim oDV As New DataView(oDS.Tables("Customers")) oDV.Sort = "CustomerName ASC, ContactName ASC" oDV.ApplyDefaultSort = True DataGrodl.DataSource = oDV End Sub

0 0

Post a comment