ms-accessvb6remote-accessoledbconnection

When the Table was opened by other person, How to select the opened table from the other computer


When the Table was opened by other person, how to select the opened table from the other computer?

Using VB 6 and Access Database

I want to select the table from the other computer when the table was opened by the other person or other software.

Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & databasetext.Text & ""
Cn.Open
    
cmdCardEvent.ActiveConnection = Cn
cmd.ActiveConnection = Cn
   
sql2 = "select * from table"
    
If rsCardEvent.State = 1 Then rsCardEvent.Close
rsCardEvent.Open sql2, Cn, adOpenStatic, adLockOptimistic
cmdCardEvent.CommandText = sql2
Set rsCardEvent = cmdCardEvent.Execute

   
Cn.Close

" & databasetext.Text & " = textbox (Database path)

But it showing error:

could not use; file already use

I want to access the table, if it is opened.


Solution

  • If I am reading your code correctly you have opened a recordset and should have the data you want with the line

    rsCardEvent.Open sql2, Cn, adOpenStatic, adLockOptimistic
    When you try to execute the command obejct you still have an open recordset and get an error.