datagrid show

shingo99

Active member
Joined
Jul 19, 2004
Messages
31
hi..i have done the coding below
Code:
Dim sql As String
        Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\LibrarySystem.mdb")
        MyConnection.Open()

        Dim da As New OleDbDataAdapter
        sql = "SELECT e.Product_code, f.Item_code FROM Products e, Items f WHERE e.Product_code=f.Product_code"
        da.SelectCommand = New OleDbCommand(sql, MyConnection)
        Dim ds As DataSet = New DataSet

        da.Fill(ds)
        DG1.DataSource = ds
the code is working
but the only problem is that the datagrid wont show out the table
i have to click on the extesion that is in the datagrid (+) in order to show it
im not sure where i should post this..but can help me?
i wish the data to be show in datagrid after this code is complie
and the datagrid will show the data like a table
thank you in advance
 
this happens because you didnt specify a table that is inside dataset
the correct code in your example is:

Code:
DG1.DataSource = ds.Tables(0) or
DG1.DataSource = ds.Tables("Table")

:)
 
Back
Top