What dataadapter should I use with an Access Database?

  • Thread starter Thread starter clusardi2k
  • Start date Start date
C

clusardi2k

What dataadapter should I use and can I use something such as
DataDirectory in the connection string? Can you give me an example?

Thanks,
Christopher Lusardi
 
On 12 Jun 2006 08:53:38 -0700, (e-mail address removed) wrote:

¤ What dataadapter should I use and can I use something such as
¤ DataDirectory in the connection string? Can you give me an example?

Below is an example:

Dim AccessConnection As System.Data.OleDb.OleDbConnection

Try
AccessConnection = New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & FilePathToDatabase)

AccessConnection.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT ...", AccessConnection)

Dim ds As New DataSet

da.Fill(ds, "MyDataTable")

frmMain.DataGrid1.SetDataBinding(ds, "MyDataTable")

Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
AccessConnection.Close()

End Try


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Back
Top