Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1431
  • Last Modified:

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
0
b3cf
Asked:
b3cf
1 Solution
 
gregasmCommented:
Look here, this is a useful guide to creating a connection and accessing data in vb.net with ADO.NET managed oledb provider.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingconnectiontoaccessdatabase.asp
0
 
gregoryyoungCommented:
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
0
 
monkesdbCommented:

    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
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now