[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

URGENT ODBC ERROR

Posted on 1998-06-23
9
Medium Priority
?
303 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 240 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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.
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…
Suggested Courses

650 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