Solved

Run-time error 3051 Read-only

Posted on 1998-12-17
10
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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
 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 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