none
UpdateDataSet - Only require update but its asking for insert RRS feed

  • Question

    1. I have a datagridview which is populated without using a dataset.
    2. I make changes to the datagridview and I want to update every single row using a batch update method.
    3. Upon update I convert all the rows in the datagridview to a dataset.
    4. Now i call UpdateDataSet like so db.UpdateDataSet(customerDS, "Customers", null, updateCmd, null, UpdateBehavior.Transactional, 0);

     

    However this throws an error "Update requires a valid InsertCommand when passed DataRow collection with new rows." The UpdateDataSet thinks that this data set is new which it is but im forcing an update, why would it complain about an insert?

     

    1. If i switch the call to db.UpdateDataSet(customerDS, "Customers", updateCmd, null, null, UpdateBehavior.Transactional, 0);

     

    So now the insert command is using the update command then the update works as its calling the update procedure.

    Does anyone see any problems with using the update command in the insert command place? Yes its calling the insert command but the insert command is actually just the update command so there are no inserts at all.

    If this is a problem, how can I get around that error stated above.

     

    Thanks for your time.

    Cheers.




    • Moved by Leo Liu - MSFT Tuesday, March 29, 2011 1:55 AM Off-topic, moved for better support. (From:Visual C# Express Edition)
    Saturday, March 26, 2011 10:44 AM

Answers

  • Don't know why you don't want to use a DataSet to bind to your DataGridView ... seems that would be easier. However, you may have some legitimate reasons for this architecture, so I won't debate that at the moment.

    Does anyone see any problems with using the update command in the insert command place? Yes its calling the insert command but the insert command is actually just the update command so there are no inserts at all.

    I don't see any reason that the above should be a problem, so since it works fine, what the heck ... go with it.


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Saturday, April 9, 2011 5:14 PM

All replies

  • I'm moving your thread into the ADO.NET DataSet Forum for better support. Thanks.
    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 29, 2011 1:55 AM
  • Hi qhuynh,

    Welcome.

    The metod:

     

    This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.(http://msdn.microsoft.com/en-us/library/bb748738(v=pandp.31).aspx)

    I think you can use DataAdapter to update your dataset, you can refer here: http://support.microsoft.com/kb/308507

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 31, 2011 7:44 AM
    Moderator
  • Hi qhuynh,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 5, 2011 3:05 AM
    Moderator
  • Hi,

    Are you saying that the updatedataset method is outdated? It doesn't appear to be deprecated or anything. I just want to know the easiest way to do a bulk update from a datagridview without loading a dataset into it as I have described above.

    Cheers

    Tuesday, April 5, 2011 8:37 PM
  • Don't know why you don't want to use a DataSet to bind to your DataGridView ... seems that would be easier. However, you may have some legitimate reasons for this architecture, so I won't debate that at the moment.

    Does anyone see any problems with using the update command in the insert command place? Yes its calling the insert command but the insert command is actually just the update command so there are no inserts at all.

    I don't see any reason that the above should be a problem, so since it works fine, what the heck ... go with it.


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Saturday, April 9, 2011 5:14 PM