Solved

URGENT ODBC ERROR

Posted on 1998-06-23
9
296 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
[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
  • 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
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

 

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

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 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