Solved

URGENT ODBC ERROR

Posted on 1998-06-23
9
295 Views
Last Modified: 2012-06-27
I CREATE THE DNS FOR THE DATABASE,(AND I DIDN´T PUT THE DATABASE IN READ ONLY). BUT WHIT THIS CODE WHEN I ADD A NEW RECORD, I HAVE THE ERROR "THIS DATABASE IS READ ONLY":

Dim wrkODBC As Workspace
Dim dbODBC As Database
Dim rstODBC As Recordset
Set wrkODBC = CreateWorkspace("WorkspaceODBC", "admin"_
, "", dbUseODBC)

Set dbODBC = wrkODBC.OpenDatabase("Calificador",_ dbDriverNoPrompt, False,_ "ODBC;DATABASE=Calificador;UID=;PWD=;DSN=Calificador")

Set rstODBC = dbODBC.OpenRecordset("SELECT * FROM CalDor")

rstODBC.Addnew 'THE ERROR OCURE IN THIS LINE
0
Comment
Question by:mexico
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 1

Expert Comment

by:kesonline
ID: 1464114
The recordset you are opening is an SQL query. Since it is not real data, just a subset there of, you can't add to it. I think you should be able to do this, depending on your db's layout:

Set rstODBC = dbODBC.OpenRecordset("CalDor") 'CalDor is the table name

Hope this helps.
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1464115
mexico,

  If you use OpenRecordSet with only passing a Select SQL statement, it will open a readonly recordset by default. Therefore, if you want to open a recordset for update, try this:

Set rstODBC = dbODBC.OpenRecordset("SELECT * FROM CalDor", _
                                   dbOpenDynaset)    

For more setting/parameter such as locking, look for the help of "OpenRecordset method" in your VB help.

I summit this as a comment, if it work, please reject current answer and let me lock the answer.

Regards.
0
 

Expert Comment

by:Ajoy
ID: 1464116
Set dbODBC = wrkODBC.OpenDatabase("Calificador",_ dbDriverNoPrompt, False,_ "ODBC;DATABASE=Calificador;UID=;PWD=;DSN=Calificador")

Here while opening the database you have not specified the ACCESS type i.e read only/write only etc. So by default it takes read only.This will work so give me the points.

0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

Author Comment

by:mexico
ID: 1464117
I TRY THE ANSWER AND THE COMMENTS, AND I STILL HAVE THE SAME ERROR. ANY NEW IDEA...
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1464118
mexico,

Try this:
Set rstODBC = dbODBC.OpenRecordset("SELECT * FROM CalDor", _
                                   dbOpenSnapshot,dbConsistent)
rstODBC.AddNew


Is your database Jet DB or remote server database?    
0
 
LVL 1

Expert Comment

by:kesonline
ID: 1464119
If you want, I can run through the code for you. What kind of DB are you using? If you can, send the DB and the code to ben@kescom.net, and I'll check it out for you.
0
 

Author Comment

by:mexico
ID: 1464120
WELL, I TRY THE YOWKEE COMMENT, AND IN THAT LINE I HAVE THE RUN TIME ERROR 3001.
AND THE TYPE OF DATABASE THAT I AM USING IS A NORMAL JET DB, WHIT THE TABLE OF CalDor, AND ONE FIELD. AND THE CODE THAT I USE IS THE CODE THAT IS AT TOP.
SOMEBODY HAVE OPEN BEFORE A DATABASE WHIT ODBC... OR HAVE A CODE THAT'S WORK WHIT ODBC  
0
 
LVL 1

Expert Comment

by:kesonline
ID: 1464121
Why don't you just open it as a regular Jet database, instead of an ODBC data source? Also, in your ODBC control panel, you may not have the data source correctly set up.
0
 
LVL 1

Accepted Solution

by:
shagnasty earned 120 total points
ID: 1464122
I've had no end of trouble adding to ODBC datasources.  I solved 'em all by building an SQL INSERT INTO statement and then executinging it against the DB.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

856 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