Link to home
Start Free TrialLog in
Avatar of bramsquad
bramsquadFlag for United States of America

asked on

trouble with datagrid population

im trying to populate a datagrid from an oledb connection (ms access db) programmatically.  ive found this solution in C#, and tried to convert it to vb, and alas, it doesnt work.

http://www.c-sharpcorner.com/database/data_view_1.asp

here is what i think is the equivelent code in vb.

        Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + tbl + ";Persist Security Info=False"
        Dim conn As New OleDb.OleDbConnection(connectionstring)

        Dim adapter As New OleDb.OleDbDataAdapter("select * from tblFinal", conn)
        'create a new dataset
        Dim ds As New DataSet
        'fill dataset
        adapter.Fill(ds, "tblFinal")

        'attatch dataset to datagrid
        DataGrid1.DataSource = ds.DefaultViewManager

thanks in advance!

~bramsquad
Avatar of mmarinov
mmarinov

Hi,
you have to add DataGrid1.DataBind() and the end

Regards,
B..M
Avatar of bramsquad

ASKER

databind() is not an option, there is a databindings() but thats about it
DataGrid1.DataBind() is needed only for web applications (not for winforms)



Instead of this line
  DataGrid1.DataSource = ds.DefaultViewManager

use

DataGrid1.DataSource = ds ' if you have only 1 datatable in the dtaset
or

DataGrid1.DataSource = ds.Tables("YourTableName')
ASKER CERTIFIED SOLUTION
Avatar of ramesh12
ramesh12

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial