MDB to Datagrid

Joined
Nov 30, 2007
Messages
1
Reaction score
0
I am trying to load a database table into a datagrid. I have already tried several snippets and methods and I keep getting the same result: nothing shows up...

Here's my code:

Code:
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\StudentInformation.mdb"
        Dim myConnection As OleDbConnection = New OleDbConnection
        myConnection.ConnectionString = connString
        ' create a data adapter
        Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Table1", myConnection)
        ' create a new dataset
        Dim ds As DataSet = New DataSet
        ' fill dataset
        da.Fill(ds, "Table1")
        ' Attach DataSet to DataGrid
        DataGrid1.DataSource = ds.DefaultViewManager
    End Sub

The table's name is correct, in Access the same query returns results, in VS.NET 2005 the datagrid does not get filled up. Any ideas?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top