2012-11-25 58 views
0

我有訪問密碼保護的數據庫。 我正在使用Visual Studio 2010和ODBC。用密碼保護的M Access 2003文件連接Visual Studio使用Odbc

必須添加什麼行代碼才能成功連接到訪問受保護的文件?

我使用這個代碼:

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 

回答

2

添加到您的CreateConnection()函數代碼:

Public Shared Sub CreateConnection() 
     con = New OdbcConnection 
     'con.ConnectionString = "Dsn=XXX" 
     con.ConnectionString = "Dsn=XXX;uid=sa;pwd=passwordRIGHT;" 
     con.Open() 
End Sub 

Here是去幾個DBS

方式