Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    34

    Unanswered: cannot update recordset, read only?

    I've been going crazy trying to update one of my recordset's entries with a new value, but I keep getting an error about the recordset not being updatable Here's my code, can someone tell me what's being done wrong here? I've even tried playing around with the rs.cursortype and rs.locktype properties with no avail.

    dim rs as adodb.recordset
    dim cnn as adodb.connection

    set rs = new adodb.recordset
    set cnn = new adodb.connection

    cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\documents and settings\username\desktop\db3.mdb"
    cnn.Open

    Set rsdat = cnn.Execute("Select * from Customer")

    rsdat.AddNew
    rsdat("cust_id").Value = "1224"
    rsdat.Update

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    This is what Access Help has to say about the ADO Connection Execute command
    The returned Recordset object is always a read-only, forward-only cursor. If you need a Recordset object with more functionality, first create a Recordset object with the desired property settings, then use the Recordset object's Open method to execute the query and return the desired cursor type.
    ??

    I had to look because I have never used Execute to create a recordset that returns records, only rs.Open .....

    MTB

  3. #3
    Join Date
    Oct 2005
    Posts
    34
    Quote Originally Posted by MikeTheBike
    Hi

    This is what Access Help has to say about the ADO Connection Execute command


    ??

    I had to look because I have never used Execute to create a recordset that returns records, only rs.Open .....

    MTB
    That seems to have done the trick. I used the regular rs.open method and it worked. I always used cnn.execute because that's how I learned from one particular project I saw only and have used it ever since. I will now use this method instead as it seems to be more correct.

  4. #4
    Join Date
    Dec 2004
    Location
    Coon Rapids, Minnesota
    Posts
    41
    I could be wrong on this - so if I am someone please let me know - but I believe that the execute command returns faster than the open command so it does have its uses. I have used execute on occasion when I am just pulling information from a table in a loop knowing that I dont need to update the table at 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
  •