Solved

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

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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.
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…

729 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