Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ADODC with password protected database

Status
Not open for further replies.

wawanz

Programmer
Aug 29, 2002
62
ID
I have a problem using adodc to access password protected database, I'm using stand alone PC, I got error message "Can't start your application. The workgroup information file is missing or opened exclusively by another user". anyone can help ? here are my code :

Adodc1.ConnectionString =
"Provider = Microsoft.Jet.OLEDB.3.51"
";Data Source = C:\Test,mdb"
";Persist Security Info=False"
adodc1.CommandType = adCmdTable
adodc1.RecordSource = "test"
adodc1.Password = "some password"
adodc1.refresh

 
Hi

Try This - it solved that exact problem for me

Public Sub ConDB(TheSql As String)

Set Ecn = Nothing
Set Ers = Nothing

Set Ecn = New ADODB.Connection
With Ecn
.ConnectionString = "Provider=" & dbProvider & ";Data Source=" & dbpath & _
";Mode=ReadWrite;Persist Security Info=False;" & _
"Jet OLEDB:Database Password=" & DBPas
.CursorLocation = adUseClient
.Open
End With

sql = TheSql
Set Ers = New ADODB.Recordset
Ers.Open sql, Ecn, adOpenDynamic, adLockOptimistic
 
First open your connection. (I leave mine open for the duration of the app since the user may have to connect via modem and this allows for one single dial up, but you may want to open and close as needed.)
Then you can use statement 1 or statement to hit the database for data. The first is standard with little overhead. The second allows you to use the filtering and sorting methods since it is holding the data at the client level.

Dim zLocalCOnnection As New ADODB.Connection
Dim RsAs New ADODB.Recordset


Call zLocalConnection.Open("Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & App.Path & "\mes1.dst;" & _
"Uid=admin;" & _
"Pwd=12345")

sSql = "Select * From Table"

STATEMENT 1
Call Rs.Open(sSql, zLocalConnection, adOpenKeyset, adLockOptimistic)

STATEMENT 2
With Rs
.CursorLocation = adUseClient
.Open Source:=sSql, ActiveConnection:=zLocalConnection, CursorType:=adOpenKeyset, LockType:=adLockOptimistic
End With
 
wawanz, I can't help observing that your filename here is "test,mdb", that is has a comma where there should be a period. I don't think that's the source of that error, though.

A few things about cursors:

The rs with the least overhead is generally the default, adOpenForwardOnly. Keyset is not only updatable, it only returns the key until you actually request a particular record. Therefore, quick to open, slow to move through the first time.

For both code examples, when you set cursorlocation to adUseClient, you also set cursortype to adOpenStatic. Therefore the cursortype setting in your recordset's open statement is ignored, and the cursortype is actually adOpenStatic.

Although the Sort property may only be used on client side recordsets, this is not true of the Filter property.

Check "nickel tour of ado's recordset types" in faq for more info.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top