Solved

Run-time error 3051 Read-only

Posted on 1998-12-17
10
218 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a duplicate finder Application 9 120
How to debug this code 7 61
Protecting vb6 & .Net code Obfuscation 18 121
Set email body to html using vbscript 6 41
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

785 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