Link to home
Start Free TrialLog in
Avatar of b3cf
b3cf

asked on

How to connect to Access using VB.net

Hi
  Could someone advise me on how I could connect to an Access database using a datasource with VB.Net and create a recordset.

Any help is greatly appreciated
thanx
ASKER CERTIFIED SOLUTION
Avatar of gregasm
gregasm

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
Dim MyConn as OleDbConnection
Dim ConnStr as String
ConnStr=""Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\MyApp\MyDataBase.mdb"

MyConn= new OleDbConnection(ConnStr)
If u have database Protected with Userid add "Userid=xxxx;Password=xxxxx" to the above string

Once Connection is Opened other opearations are same as common OleDb operations

    Dim rs As New ADODB.Recordset
   
    rs.Source = "SELECT * FROM Table"
    rs.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""C:\dir\db.mdb"""
    rs.Open