?
Solved

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

Posted on 1998-08-22
3
Medium Priority
?
210 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
[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 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 100 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

Industry Leaders: 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!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

649 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