Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6, MySQL, ODBC and Error 3027 - Database or object Read Only.

Status
Not open for further replies.

ShaneBrennan

Programmer
May 19, 1999
198
GB
I'm having a problem adding a new record to my MySQL database.

I have a database called tblLog (Currently empty) with 3 fields: ClientID, ProductID and SecurityID - all varchar

All I want to do it add a new record, but the I keep getting the following error message:

"Run-time error '3027'" "Cannot update. Database or object is read-only."

I'm quite new to mySQL and connecting databases through VB6 (I Usually write all database applications with MS Access)

I'm sure I have set all the access rights/grant permissions correctly.

Below is a cut down version of the code, but the error occures on the rs.addnew command.

Any help would be gratefully received.


private sub InsertNewRow
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset

Dim strConnection As String

strConnection = "ODBC;DSN=softwarelicense;UID=shane;PWD=frogger"

Set ws = CreateWorkspace("ODBCWorkspace", "", "", dbUseODBC)

Set db = ws.OpenDatabase("", False, False, strConnection)

Set rs = db.OpenRecordset("Select * from tblLog", dbOpenDynaset, dbExecDirect, dbOptimisticValue)


rs.AddNew
rs!ClientID = "Cli-0001"
rs!ProductID = "0123"
rs!SecurityID = "97661"

rs.Update
rs.Close
Set rs = Nothing

End Sub

Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk


 
Verify that dbOpenDynaset is supported by your database. If it isn't, then you will get the default of a read-only cursor.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Hi ArtieChoke

I threw my teddies out of the pram with this one, and tried another method. I think it's ADO and it works just fine now.

Can you please enlighten me on how to check that the Database is capable of supporting dbOpenDynase? I'me using MySQL.

Thanks in advance.

Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk


 
Using ADO is the better choice here. Check out the supports method of the recordset - it will tell you what type of cursors are supported for your database. Note: an opendynaset cursor is strictly DAO. ADO has the keyset cursor, which is similar.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top