■ MDB 연결을 구하는 방법을 보여준다.
▶ 예제 코드 (VB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
Public Function GetMDBConnection(strMDBFilePath As String) As ADODB.Connection Dim pConnection As ADODB.Connection Dim strConnectionString As String Set GetMDBConnection = Nothing On Error GoTo ErrorLabel Set pConnection = New ADODB.Connection strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strMDBFilePath pConnection.Open strConnectionString On Error GoTo 0 Set GetMDBConnection = pConnection Exit Function ErrorLabel: End Function Public Function GetMDBConnection(strMDBFilePath As String, strUserID As String, strPassword As String) As ADODB.Connection Dim pConnection As ADODB.Connection Dim strConnectionString As String Set GetMDBConnection = Nothing On Error GoTo ErrorLabel Set pConnection = New ADODB.Connection strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strMDBFilePath + ";User ID=" + strUserID + ";Jet OLEDB:Database Password=" + strPassword pConnection.Open strConnectionString On Error GoTo 0 Set GetMDBConnection = pConnection Exit Function ErrorLabel: End Function |