Results 1 to 6 of 6

Thread: [2005] why dataadapter fails in updating 2 diffrent tables

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    130

    [2005] why dataadapter fails in updating 2 diffrent tables

    Hi
    i make the dataadapter get data and view in datagridview successfully
    and the same adapter let it get another table by changing the select statement and view it in another datagridview till now ok.

    i have 2 update buttons every one for each table
    the first dataset i call
    da.update(ds1)

    and the second
    da.update(ds2)

    i found that the second one raise exception says "Object renfrence is set to none" means that the dataadapter is no longer exists ?!

    any explanation
    by the way i can make both tables in one dataset and they will work. but i want explanation for this error.

    thanks in advance.

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: [2005] why dataadapter fails in updating 2 diffrent tables

    Hi.
    Did you put the NEW keyword when you declared dataadapter?
    "The dark side clouds everything. Impossible to see the future is."

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    130

    Re: [2005] why dataadapter fails in updating 2 diffrent tables

    thanks for reply

    i will check my code again and tell you

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    130

    Re: [2005] why dataadapter fails in updating 2 diffrent tables

    yes i create new adapter and i don't know why still the error
    but one question
    can i fill the dataset with an adapter and update it with another one ?

    thanks in advance.

  5. #5
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: [2005] why dataadapter fails in updating 2 diffrent tables

    I think you remove the data bindings when you renew the data adapter. Create a data adapter for each data table and give it a try.
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] why dataadapter fails in updating 2 diffrent tables

    You're abusing the DataAdapter. The purpose of a DataAdapter is to provide the link between a single result set and the database. The DataAdapter encapsulates the four Commands that will operate on that result set. You should not be changing any SQL code in DataAdapter. The whole point is that the DeleteCommand, InsertCommand and UpdateCommand are supposed to save the changes made to the data retrieved by the SelectCommand. If you change the SelectCommand to get different data then what do the other commands relate to? If you are operating on two different result sets, which basically means DataTables, then you should have two different DataAdapters.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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