CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2001
    Posts
    33

    Update several records at the same time

    I need to update several records at the same time.
    I used
    for i = 0 to 3
    rs("name") = UCase(Trim(txtName(i).Text))
    rs("age") = UCase(Trim(txtAge(i).Text))
    rs("preference") = txtPref

    rs.Update
    next i

    It failed to work :
    "Method of update of object recordset failed"

    Can anyone help me?


  2. #2
    Join Date
    Mar 2001
    Posts
    90

    Re: Update several records at the same time

    Hi

    If u use the Update Method, U will have to use
    either Addnew or Edit method.

    The code should look like

    for i = 0 to 3

    rs.Addnew ( or ) rs.Edit

    rs("name") = UCase(Trim(txtName(i).Text))
    rs("age") = UCase(Trim(txtAge(i).Text))
    rs("preference") = txtPref

    rs.Update
    next i


    All the best
    Bye Bye take Care
    Vijooo




  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Update several records at the same time

    ...and use edit to modify existing records. Use addnew to create a new record. Do not forget to rate Vijoo if he helped you.

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Feb 2001
    Posts
    33

    Re: Update several records at the same time

    Vijooo, I have tried what you have suggested, but there is no Edit method !!!
    I can only find EditMode method instead.
    When I used rs.EditMode, it prompted an error "Invalid use of property".

    What's wrong ???
    Please help me


  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Update several records at the same time

    Edit exists only for DAO, for ADO you don't have to use rs.Edit

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  6. #6
    Join Date
    Mar 2001
    Posts
    90

    Re: Update several records at the same time


    HI

    If u r using ADO, then u wont be having the
    Edit Method. If u r working with DAO then it
    can be used.

    Anyway , Idf u want to edit a Particular record
    Then use the Execute Method with SQL Query.
    Sql query will look like this.

    For Edit
    Update [Table Name] Set [Field Name] = Values
    Where Condition.

    For Addition
    Insert Into [Table Name] ( values )

    Make the queries to execute in Execute Method.
    This is the best way to work with ADO.


    Mail me back about the status.
    All the best
    Take Care Bye Bye
    Vijooo


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

Featured