sorry, I just noticed you're doing this with one connection. You may need to unprotect the target database before you can insert into the database in this fashion. You should be able to use this function to set its password to an empty value, and then when you're done, to put a new password in place.
Main Topics
Browse All Topics





by: HadmackerPosted on 2002-11-19 at 06:31:52ID: 7468796
The MSDN has your answer online.
library/de fault.asp? url=/libra ry/ en-us/o deopg/html / deovrwork ingwithdat abasepassw ordsinvbac ode.asp
I have included the link at the bottom of this comment, but here is the excerpt in particular you will want to use:
Function OpenProtectedDB(strDBPath As String, _
strPwd As String)
Dim cnnDB As ADODB.Connection
Set cnnDB = New ADODB.Connection
' Open database for shared (by default), read/write access, and
' specify database password.
With cnnDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = strPwd
.Mode = adModeReadWrite
.Open strDBPath
End With
' Code to work with database goes here.
cnnDB.Close
Set cnnDB = Nothing
End Function
It's explained in more depth here:
http://msdn.microsoft.com/