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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable to write to DB---read only errors---ADO--DB is readable

Status
Not open for further replies.

durda

Programmer
Jan 3, 2003
25
US
This is the error I get when I try to update a database field.

Run-time error'-2147467259(80004005)':
[Microsoft][ODBC dBase Driver] Cannot update. Database or object is read-only

I've already checked the read only property to my database and it is not set to read only. I also made sure that a previous "rs" was closed before reconnecting.

Here is my code:
in a module
Public Conn As New ADODB.Connection
Public RS As New ADODB.Recordset
Public StrFileName As String

Private Sub Form_Load()
Conn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
"Dbq=" & App.Path & "\db\"
End Sub


on a different form is where I try to connect and update the database.

Private Sub CmdMenu_MouseDown(Index As Integer, button As Integer, Shift As Integer, X As Single, Y As Single)

StrFileName = "buttons.dbf"
RS.Open "Select * from buttons", Conn, adOpenKeyset, adLockOptimistic, adCmdText
RS.MoveFirst
Do Until RS.EOF
If RS.Fields("MENU_ID") = NdxValue Then
RS.Fields("BLEFT") = FrmMenuDesign.CmdMenu(NdxValue).Left
RS.Fields("BTOP") = FrmMenuDesign.CmdMenu(NdxValue).Top
RS.Update
RS.Close
Exit Sub
End If
RS.MoveNext
Loop
End If
End If
rs.close
End Sub


The line causing the run-time error is rs.update. I can read the database without any problems. Oh yeah, I've already added the ado 2.1 Library reference.

Anyone have any ideas

thanks in advance
 
Does the user running the program have write privs to the database file/directory or does the dbase file have it's attribute set to read-only?

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
yes, im using win98 and I have only one profile setup. I can access the database with another program and I am able to write to it with that program. Its a spreadsheet program.

 
Oh yeah, the files and dir are not set to read only either.
 
The only thing I can see is it's possible the cursor type of adOpenKeyset is not supported - then it defaults to a forward-only cursor, which is read-only.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
ArtieChoke,
Ill check into that, thanks. Just an update. I copied all my files into my work PC and it wwrites to the database just fine. Really confused now. I think i'll try to update mdac and the other update that goes along with it, forgot what its call right now. Thanks for your help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top