Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

URGENT ODBC ERROR

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
mexico
Asked:
mexico
  • 3
  • 2
  • 2
  • +2
1 Solution
 
kesonlineCommented:
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
 
yowkeeCommented:
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
 
AjoyCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mexicoAuthor Commented:
I TRY THE ANSWER AND THE COMMENTS, AND I STILL HAVE THE SAME ERROR. ANY NEW IDEA...
0
 
yowkeeCommented:
mexico,

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


Is your database Jet DB or remote server database?    
0
 
kesonlineCommented:
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
 
mexicoAuthor Commented:
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
 
kesonlineCommented:
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
 
shagnastyCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now