PDA

Click to See Complete Forum and Search --> : Can't Update .. Database is read-only


chengdm
Nov 17th, 1999, 02:24 AM
Hey All,

I am fairly new to the VB world. Am trying to do a simple insert statement using VB and got this error message .. Can't Update. Database or object is read-only. error number 3027.

Running on VB 5 and SQL Server 7. Works fine with Access though. Attached below is a sample code that I am using. Any help will be greatly appreciated. Thanks a million.


Dim myDB As Database
Dim testTable As Recordset

Set myDB = OpenDatabase(recbooks, False, False, "database=recbooks;uid=sa;pwd=;dsn=connectionString")
Set testTable = myDB.OpenRecordset("narratorInfo")
With testTable
.AddNew
!lastname = "duh1"
!firstname = "duh1"
.Update
End With

Lloyd
Nov 17th, 1999, 02:28 AM
Hi there!!

Have you checked and make sure the database is closed? Also try to right-click the database in Windows Explorer and see if the Read Only Attribute is checked. If it is uncheck it. Good Luck!!

Lloyd

chengdm
Nov 17th, 1999, 02:32 AM
Yup done all that.

End With
myDB.close

Ran other languages to test the db and it managed to update or delete or insert into the same database. Its only VB that is giving the problem. Thanks for the fast response.

lambela8
Nov 19th, 1999, 11:40 AM
This happens to me a lot also. The thing that I have found is that I am opening multiple tables by a join (or a non-updatable recordset) If you are joining two tables, make sure you don't include both key fields in your select statement - wherever you did this at.

If it is happening on a single table, you would have to be out of access or make sure it isn't read only.

L

chengdm
Nov 19th, 1999, 11:44 AM
I managed to find the solution. VB gives you read only because the table that you are quering does not contain a primary key. Include a primary key in that table and everything will work just fine.

Cheers to all..