retreiving updated row in storedProc using "refresh data set" option

I have generated the stored procedures for database using data adapter wizard.  I selected the "refresh data set" option in the advanced sql generation options screen.

This puts a select statement at bottem of the update statment in the stored procedure.

How do I call this stored procedure and get the returned row into a dataset  
Could you show me the code for calling this sp since I usually use the

.ExecuteNonQuery() on the command object which doesnt' generate a dataset

Thanks



Answer this question

retreiving updated row in storedProc using "refresh data set" option

  • akeiii

    When using DataAdapters, you shouldn't call the Command objects directly because you're missing out on one of the big advantages of DataAdapters - letting them figure out which combination of Update/Insert/Delete commands need to be executed to write data changes back to the database. Here's some sample code demonstrating proper use of a DataAdapter. salesDataAdapter is a DataAdapter that was generated via the standard wizard:

    // Usually done in Form_Load or similar method
    SalesDataSet sales = new SalesDataSet();
    salesDataAdapter.Fill(sales);
    // Display the dataset

    // Allow user to update, modify, and delete rows via a DataGrid or other mechanism
    // User clicks "Save Changes" - This code would be in btnSaveChanges_Clicked
    salesDataAdapter.Update(sales);


  • Mark Schmidt-MSFT

    Yes, I understand, but stored procedures have to be used.  Shop rules, so that's why I posted my question: to make the work of building these sp's a little easier.

    Thanks

  • kyus

     smhaig wrote:
    Yes, I understand, but stored procedures have to be used.  Shop rules, so that's why I posted my question: to make the work of building these sp's a little easier.

    Thanks


    smhaig,

       You still can use stored procedures, you just have to change the Select, Update, Delete and Insert command properties of the adapter to use the stored procedures that you have definied (and not queries).

       Hope this helps.

              - Nicholas Paldino [.NET/C# MVP]
              - mvp@spam.guard.caspershouse.com

  • Sethimus

    Hi,

    Is it possible that a Stored Procedure to return a value directly Is it a User Defined Function (UDF) that you might be using




    cheers,


    Paul June A. Domag

  • retreiving updated row in storedProc using "refresh data set" option