• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

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
0
dosyl
Asked:
dosyl
  • 7
  • 3
1 Solution
 
dosylAuthor Commented:
Edited text of question
0
 
dosylAuthor Commented:
Edited text of question
0
 
mdouganCommented:
I think this is an easy one.  The open database syntax is:
OpenDatabase(Name, Read Only, Exclusive, Connect String)

The default for Read Only is False, but you are setting Exclusive to True, so, you are getting the exact error message you should expect.  Try:

   Set dbCli = WSpace.OpenDatabase(App.Path, False, False, "dBASEIV;")

By the way, it's always a good programming practice to type in the defaults anyway.  It makes your code more readable to someone who may not know what the defaults are.

MD
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
dosylAuthor Commented:
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.
0
 
mdouganCommented:
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
0
 
dosylAuthor Commented:
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.
0
 
mdouganCommented:
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
0
 
dosylAuthor Commented:
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.
0
 
dosylAuthor Commented:
The drivers are installed because if i put a datacontrol all works,
it's only when i try to open the database with : .openDatabase( )
0
 
dosylAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now