Link to home
Start Free TrialLog in
Avatar of dosyl
dosyl

asked on

Run-time error 3051 Read-only

I have a dataControl on a form, read-only is False with the connect property  dBase IV. I try to open an other file with the connect property dbase IV with read-only true, but i'm not able. I have the error message: Run-time error 3051,cannot open file d:\electr. it's already open by another user, you need permission to view data.

DataSoumis is set in the property window.

Here is my code:

Dim WSpace As Workspace
Dim dbCli As Database
Dim rstSoumis As Recordset
Dim rstCli As Recordset

DataSoumis.Refresh
Set rstSoumis = DataSoumis.Recordset

    rstSoumis.MoveLast
    Set WSpace = DBEngine.Workspaces(0)
    Set dbCli = WSpace.OpenDatabase(App.Path, , True, "dBASEIV;")
    Set rstCli = dbCli.OpenRecordset("CLIENTS", dbOpenTable)

HELP ME IF YOU CAN PLEASE, THANK'S A LOT.
Donald
Avatar of dosyl
dosyl

ASKER

Edited text of question
Avatar of dosyl

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of mdougan
mdougan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dosyl

ASKER

I try what you writed. Now, i have the  error couldn't find installable ISAMS.
And i don't understand in the VB help the options of opendatbase are : dbname,options, readonly,connect.
It's not write Exclusive.
Thank's for your help, i appreciate.
I may have had the Read-Only and Exclusive parameters backwards, but the False, False will work either way.  Since it corrected your original problem, I think that it has.  

Now, as for the installable ISAMS, when you installed VB you had the option of installing drivers for different databases.  You would have had to select the dbaseIV driver at that time, to be able to run this code now.  You can search for your VB INI file, and in that, there should be a section called Installable ISAMS.  This will tell you what you have installed.  If you don't have an entry for the dbaseIV driver, then you could run the VB setup again, and install it.

MD
Avatar of dosyl

ASKER

In vb5 you don't have options of installing drivers. In vb3 you had it. I believe in vb5 it is in odbc, but i don't know how to use it. If you're able to do code for a pgm. works give me it, and if you must to add something in vb5 (like in the references) tell me what to do.
Thank's.
You're partially correct.  In VB5, the place where they ask you about the installable ISAMS is in the ODBC setup option in the VB5 installation.  If you skip the ODBC setup, you'll miss the installable ISAMS as well.  You must have these drivers (DLLs) installed to be able to open your dbaseIV database through VB.  And, based on the error message your said that you received, you do not have these drivers installed.  You'll need to do this before you even attempt anything else.

Once you've done this, then the code that you have should work fine.  The syntax for the OpenRecordset statement you coded looks like you are using DAO.  So, make sure that you have checked the DAO 3.5 option in the References screen for your project.

Also, from your code, I assume that the dbaseIV database files are in the same directory that your exe is in?  You are using App.Path in the OpenDatabase statement.  Be careful, sometimes when you are running in Debug mode App.Path is set to the VB directory, not the directory where your source code is.  Put a breakpoint on that line, and when you run, verify that App.Path is pointing to the directory where your dbase files are.  Otherwise, your code looks good!

MD
Avatar of dosyl

ASKER

The odbc drivers are installed for dbase IV etc. The file is odbcjt32.dll and it is installed in c:\windows\system. In references DAO 3.5 is checked.
Avatar of dosyl

ASKER

The drivers are installed because if i put a datacontrol all works,
it's only when i try to open the database with : .openDatabase( )
Avatar of dosyl

ASKER

I found the problem on microsoft site : we don't put a semicolon
after dBase IV. I remove it and it's work.
Thank's for all.