Reputation: 25058
I have an access password protected database. I am using Visual Studio 2010 and ODBC.
What line of code must be added to successfuly connect to access protected file?
I am using this code:
Imports System.Data.Odbc
Imports System
Public Class DatabaseFunctions
Shared con As OdbcConnection
Public Shared Sub CreateConnection()
con = New OdbcConnection
con.ConnectionString = "Dsn=XXX"
con.Open()
End Sub
Private Shared Sub CheckConnection()
If con Is Nothing OrElse con.State = ConnectionState.Closed Then
CreateConnection()
End If
End Sub
End Class
Upvotes: 0
Views: 483
Reputation:
Add this to your CreateConnection() function code:
Public Shared Sub CreateConnection()
con = New OdbcConnection
'con.ConnectionString = "Dsn=XXX"
con.ConnectionString = "Dsn=XXX;uid=sa;pwd=passwordRIGHT;"
con.Open()
End Sub
Here are the way to go for several dbs
Upvotes: 2