Results 1 to 5 of 5

Thread: Can't Update .. Database is read-only

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    3

    Post

    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

  2. #2
    Member
    Join Date
    Jun 1999
    Posts
    44

    Post

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    3

    Post

    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.

  4. #4
    Member
    Join Date
    Nov 1999
    Posts
    48

    Post

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    3

    Post

    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width