Solved

Why it always show "Database is Read Only" when I add a record to it.

Posted on 1998-08-22
3
201 Views
Last Modified: 2010-04-30
Hi every Genius,

I write a VB program to read/write records from/to a table using ODBC driver. I can select the records from the table
properly. But as I want to add a record to the table. It always show the error message "Can't update. Database or object is
read only". I have already check that the property of Updateable is true. Is something wrong/missing in my program or else (ie.
driver)?

Please Help me. Thanks!

My program is attached as below:

Function InsertRecord() As Boolean
Dim wrkODBC As Workspace
Dim conPubs As Connection
Dim rstTemp As Recordset

Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
"XXXXXX", "YYYYYY", dbUseODBC)

Set conPubs = wrkODBC.OpenConnection("Connection1", _
dbDriverComplete, False, "ODBC;DSN=Micro-MRP MAX; " & _
"DATAPATH=X:\APPS\MAX\DAT;UID=XXXXXX;PWD=YYYYYY; " & _
"DDFPATH=X:\APPS\MAX\DAT;")

With conPubs
Debug.Print " Connect = " & .Connect
Debug.Print " Database[.Name] = " & _
.Database.Name
Debug.Print " Name = " & .Name
Debug.Print " Updateable = " & .Updatable 'True
End With

Set rstTemp = conPubs.OpenRecordset("Header/Footer", _
dbOpenDynamic)
With rstTemp
.AddNew
!NOTENUM_47 = "A"
!NOTEDES_47 = "A"
!NOTELN1_47 = "A"
!NOTELN2_47 = "A"
!MCOMP_47 = "A"
!MSITE_47 = "A"
!UDFKEY_47 = "A"
!UDFREF_47 = "A"
!FILLER_47 = "A"
.Update
End With

rstTemp.Close

conPubs.Close

wrkODBC.Close

End Function
0
Comment
Question by:wnchan
3 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430382
Hi,
Is your database is open by MS Access or any program.
That cloud be a problem.
0
 
LVL 4

Accepted Solution

by:
trkcorp earned 50 total points
ID: 1430383
Set rstTemp = conPubs.OpenRecordset("Header/Footer", _
dbOpenDynamic,dbAppendOnly)

Change the statement above as illustrated.
0
 
LVL 2

Expert Comment

by:sbmc
ID: 1430384
Make sure the table you are updating has an index. If not update will fail.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now