edgarmtze
edgarmtze

Reputation: 25058

Connect Visual Studio with password protected M Access 2003 file USING Odbc

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

Answers (1)

user756239
user756239

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

Related Questions