Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
MS Date Picker 64 bit 32 bit issue 12 59
using web browser with BING 40 130
how to know if my Checkbox is True in VB6.0? 9 60
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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

791 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