การเชื่อมต่อ excel กับ encrypted password access 2013
Posted: Thu Jul 24, 2014 10:36 am
รบกวนหน่อยครับ ผมมีปัญหานี้มานาน หาคำตอบไม่ได้สักที ผมทำการเชื่อมต่อ MS Excel 2013 กับ ฐานข้อมูล MS Access 2013 ผ่าน code VBA
ถ้าเป็นการเชื่อมต่อปกติ โดยที่ MS Access Database ไม่ได้ติด password สามารถเชื่อมต่อได้ไม่มีปัญหา แต่พอผมใส่ password ให้ MS Access ผมยังหาทางเชื่อมต่อมันไม่ได้สักที วิธีที่ผมทำ และ environment ของผมเป็นดังนี้ครับ
Windows 8 32-bit
MS Office 2013 Professional Plus 2013
Error คือ
Run-time error '-2147217843(80040e4d)':
Not a valid password
สิ่งที่ผมสังเกตุคือ ไม่ว่าผมจะใส่ code .Properties("Jet OLEDB:Database Password") = "xxxxxx-xxx" หรือไม่ใส่ ผมก็จะได้ error นี้
รบกวนขอคำแนะนำด้วยครับ
ถ้าเป็นการเชื่อมต่อปกติ โดยที่ MS Access Database ไม่ได้ติด password สามารถเชื่อมต่อได้ไม่มีปัญหา แต่พอผมใส่ password ให้ MS Access ผมยังหาทางเชื่อมต่อมันไม่ได้สักที วิธีที่ผมทำ และ environment ของผมเป็นดังนี้ครับ
Windows 8 32-bit
MS Office 2013 Professional Plus 2013
Code: Select all
Private Const myPATH As String = "E:\MyApplications\"
Private Const myDBFILENAME As String = "myDB.accdb"
Sub myDataAccess()
Dim oConn As New ADODB.Connection
Dim oRs As New ADODB.Recordset
Dim sDBFile As String
Dim sSQL As String
Dim i As Integer
sDBFile = myPATH + myDBFILENAME
With oConn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" + sDBFile
'.Properties("Data Source") = sDBFile
.Properties("Jet OLEDB:Database Password") = "xxxxxx-xxx"
.Open
End With
If oConn.State <> adStateOpen Then Exit Sub
sSQL = "SELECT * FROM Employees"
oRs.CursorLocation = adUseClient
'source,actconn,cursortyp,locktyp,opt
oRs.Open sSQL, oConn
MsgBox oRs.RecordCount
oRs.Close
oConn.Close
End Sub
Run-time error '-2147217843(80040e4d)':
Not a valid password
สิ่งที่ผมสังเกตุคือ ไม่ว่าผมจะใส่ code .Properties("Jet OLEDB:Database Password") = "xxxxxx-xxx" หรือไม่ใส่ ผมก็จะได้ error นี้
รบกวนขอคำแนะนำด้วยครับ