Solved

Run-time error 3051 Read-only

Posted on 1998-12-17
10
216 Views
Last Modified: 2013-12-25
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
Comment
Question by:dosyl
  • 7
  • 3
10 Comments
 
LVL 1

Author Comment

by:dosyl
ID: 1498350
Edited text of question
0
 
LVL 1

Author Comment

by:dosyl
ID: 1498351
Edited text of question
0
 
LVL 18

Accepted Solution

by:
mdougan earned 50 total points
ID: 1498352
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
 
LVL 1

Author Comment

by:dosyl
ID: 1498353
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
 
LVL 18

Expert Comment

by:mdougan
ID: 1498354
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:dosyl
ID: 1498355
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
 
LVL 18

Expert Comment

by:mdougan
ID: 1498356
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
 
LVL 1

Author Comment

by:dosyl
ID: 1498357
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
 
LVL 1

Author Comment

by:dosyl
ID: 1498358
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
 
LVL 1

Author Comment

by:dosyl
ID: 1498359
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now