Hi friends....


how to connect MS.Acess database into vb.net......

is any ODBC setting needed?

Dani AI

Generated

Short summary and up‑to‑date tips that fill gaps in the thread: you do not have to use ODBC to talk to an Access file from VB.NET — ADO.NET exposes both an OLE DB provider and an ODBC provider, so you can choose the one that fits your scenario. As suggested, OLE DB is commonly used from managed code; ’s ODBC/ADODB route also works when you need a driver/DSN. (learn.microsoft.com)

Important practical notes you won’t see in the original replies: modern Access files (.accdb) require the ACE engine; the old Jet engine is legacy and has no native 64‑bit build, so bitness mismatches are the most common cause of “provider not registered” errors. On 64‑bit Windows either install the matching (x64) Access Database Engine or run your process as 32‑bit (or install the Access runtime). ()

Minimal, safe VB.NET pattern (ADO.NET, using ACE provider and parameterized queries — not the same example already posted in the thread):

Imports System.Data.OleDb

Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\path\MyDb.accdb;Persist Security Info=False;"
Using cn As New OleDbConnection(cs)
    Using cmd As New OleDbCommand("SELECT * FROM MyTable WHERE ID = ?", cn)
        cmd.Parameters.AddWithValue("?", someId)
        cn.Open()
        Using rdr = cmd.ExecuteReader()
            While rdr.Read()
                ' read fields: rdr("FieldName")
            End While
        End Using
    End Using
End Using

If you see provider/bitness errors, either install the correct Access Database Engine or compile/host for x86; for IIS apps that commonly means setting the app pool to allow 32‑bit if you must use a 32‑bit provider. (learn.microsoft.com)

If this is for a web site or anything with multiple concurrent users, prefer SQL Server (Express or full) because Access is file‑based, has fewer security/features and does not scale well; if you must use Access in ASP.NET, put the file in App_Data and give the app pool identity write permissions to the folder (Access needs to create lock files). (learn.microsoft.com)

(References above expand the brief examples posted by and and address ACE vs Jet, 32/64‑bit, provider installation, and IIS hosting traps.)

Recommended Answers

All 4 Replies

Hi friends....


how to connect MS.Acess database into vb.net......

is any ODBC setting needed?

You can connect through oleDB (no ODBC required):

Dim SelectText as String = "Select * from myTable"
 
Dim SqlConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\asp_examples1\test.mdb
 
Dim myDA As oledb.oledbDataAdapter= New oledb.oledbDataAdapter(SelectText, SqlConn)

Ned

yes, of course you'll have to make an odbc connection and in your vb.net project you have to download the odbc reference.

To open a database in vb.net:

sconbase = "PROVIDER=MSDASQL;dsn=bdraacp;"
db = New ADODB.Connection
db.CursorLocation = ADODB.CursorLocationEnum.adUseClient
db.Open(sconbase)


the string in dsn it is the odbc connection

be attention to possible errors, please use exceptions to avoid mistakes in the application.

Regards,
Guimas_Boy

yes, of course you'll have to make an odbc connection and in your vb.net project you have to download the odbc reference.

Regards,
Guimas_Boy

Guimas provides the method IF you want to use ODBC. The original question was whether or ODBC is required. See my post two above this one - the code I provided is the sum total of what's required to connect without creating an ODBC connection.

Thanks!

Ned

Hi NedFrankly...

Thanks. it will work. thank u very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.