Solved

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

Posted on 1998-08-22
3
202 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 70
Validating VB6 Function 19 56
Macro: print each sheet to pdf using ExportAsFixedFormat 11 38
Set email body to html using vbscript 6 22
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

943 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

6 Experts available now in Live!

Get 1:1 Help Now