updating a record in a Access DB Error.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: updating a record in a Access DB Error.

  1. #1
    Victoria Guest

    updating a record in a Access DB Error.


    Hi!

    I am writing a program where an Access DB is used to retrieve and display
    information. I'm having a problem when I go to update the record. I know
    that my string is OK to update the DB. On the line Set rsAssets........it
    keeps buging out. I get an invalid operation error (RunTime 3219). Can anybody
    help me with the error. I just want to upsate the rec.

    Thanx,
    Vic
    ************************************
    Private Sub cmdSave_Click()

    string1 = "Update AllInfo set shipper = ' " & txtShipper & " ' where _ MSTag
    = '" & txtMSTag & "'"
    Set rsAssets = dbAsset.OpenRecordset(string1, dbOpenDynaset)
    rsAssets.Close
    Set rsAssets = Nothing

    End Sub

  2. #2
    Phil Weber Guest

    Re: updating a record in a Access DB Error.

    > string1 = "Update AllInfo set shipper = ' " & txtShipper & _
    > " ' where MSTag = '" & txtMSTag & "'"
    > Set rsAssets = dbAsset.OpenRecordset(string1, dbOpenDynaset)


    Victoria: Your problem is that the SQL UPDATE command does not return a
    recordset. Instead of OpenRecordset, use the Execute method to do an UPDATE:

    dbAsset.Execute string1

    ---
    Phil Weber

    P.S. -- In the future, please post database-related questions to the
    vb.database.general newsgroup. Thanks!



  3. #3
    Craig Brown Guest

    Re: updating a record in a Access DB Error.


    Victoria,

    You may also want to check that shipper is not a key field. You aren't allowed
    to update key fields.

    Craig Brown



    "Phil Weber" <pweber@devx.com> wrote:
    > > string1 = "Update AllInfo set shipper = ' " & txtShipper & _
    > > " ' where MSTag = '" & txtMSTag & "'"
    > > Set rsAssets = dbAsset.OpenRecordset(string1, dbOpenDynaset)

    >
    >Victoria: Your problem is that the SQL UPDATE command does not return a
    >recordset. Instead of OpenRecordset, use the Execute method to do an UPDATE:
    >
    > dbAsset.Execute string1
    >
    >---
    >Phil Weber
    >
    >P.S. -- In the future, please post database-related questions to the
    >vb.database.general newsgroup. Thanks!
    >
    >



  4. #4
    Roy Guest

    Re: updating a record in a Access DB Error.


    "Victoria" <miwok74@hotmail.com> wrote:
    >
    >Hi!
    >
    > I am writing a program where an Access DB is used to retrieve and display
    >information. I'm having a problem when I go to update the record. I know
    >that my string is OK to update the DB. On the line Set rsAssets........it
    >keeps buging out. I get an invalid operation error (RunTime 3219). Can anybody
    >help me with the error. I just want to upsate the rec.
    >
    >Thanx,
    > Vic
    >************************************
    >Private Sub cmdSave_Click()
    >
    >string1 = "Update AllInfo set shipper = ' " & txtShipper & " ' where _ MSTag
    >= '" & txtMSTag & "'"
    >Set rsAssets = dbAsset.OpenRecordset(string1, dbOpenDynaset)
    >rsAssets.Close
    >Set rsAssets = Nothing
    >
    >End Sub



    Try the following syntax:

    string1 = "Update AllInfo set shipper = " & "'" & txtShipper & "'" & " where
    MSTag >= " & "'" & txtMSTag & "'".

    It must work unless txtShipper and txtMSTag have invalid values.They have
    to be validated before trying to update recordset.

    Regards,
    Roy


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center