Click here to Skip to main content
15,947,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

Can anybody suggest conversion of the code below to the newest version of .NET?

VB.NET
Public Function OpenOLEDBConn(ByVal DB_PATH1 As String) As OleDbConnection
        Dim ConStr1 As String
        ConStr1 = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & DB_PATH1 & ";Jet OLEDB:Database Password=" & UserPAssword & ";"
        On Error GoTo ErrTrap
        Dim AdConn1 As New OleDb.OleDbConnection(ConStr1)
        AdConn1.Open()
        Return (AdConn1)
        Exit Function
ErrTrap:
        MsgBox(Err.Description, vbCritical)
        End
    End Function


What I have tried:

I have been using the code since long for connection to Microsoft Access Database.
Posted
Updated 8-Mar-23 4:58am
v2

 
Share this answer
 
Comments
Maciej Los 8-Mar-23 10:58am    
5ed!
For older version of MS Access you should use Microsoft Jet OLE DB 4.0. For newer version: Microsoft ACE OLEDB 12.0

More details you'll find here: Access connection strings - ConnectionStrings.com[^]
 
Share this answer
 
Comments
Richard MacCutchan 8-Mar-23 11:01am    
5 back at you. As far as I can tell from my limited testing the ACE driver works with all versions.
Maciej Los 8-Mar-23 11:16am    
I think you're right. I've never tested ACE on older versions of MS Access.
Thank you.
Richard MacCutchan 8-Mar-23 11:22am    
I have not done it recently so I cannot be 100% sure.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900