Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending a DataRow to Update Stored Procedure
Message
 
 
À
22/01/2010 13:19:02
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01445383
Message ID:
01445529
Vues:
27
Hi Bonnie,

You are correct understanding that I want to avoid (or save time) going over each row. In my app user has to save changes for each row individually.

Right now I am a little overwhelmed with all the information (reading your blogs, chapter in a book on WinForm binding, and a few on-line articles). I need to write down what I have learned and make a plan on how to proceed.

Thank you very much.

>Hi Dmitry,
>
>Under the covers, the .Update() method of the SqlDataAdapter goes through your DataTable (and yes, you can have a DataTable separate and not associated with a DataSet) and for every changed DataRow, it sets up parameters for each column and then uses the appropriate Command (InsertCommand, DeleteCommand, UpdateCommand) to send an update to the database, one changed row at a time. If you have read my blog (which I think you said you did), you'd see how I recommend handling this yourself rather than using the .Update() method and a CommandBuilder.
>
>If you want to avoid having to go through every DataRow of a DataTable, you can use the GetChanges() method of a DataTable or a DataSet to send *only* what's changed to your DAL. The .Update() method probably does this also under the covers, but I don't actually know that for sure, and besides by handling that yourself on the client-side of your app, you avoid sending an entire DataSet "over the wire" to your server-side DAL if you've only got a row or two that needs updating.
>
>I don't know if this is exactly what you were asking about, but I thought I'd throw it into the mix.
>
>~~Bonnie
>
>
>
>
>>Hi,
>>
>>I was wondering if it is possible and how to send a DataRow to a SQL Server stored procedure for update? Is a DataRow object "acceptable" by a SQL Server? How would a SQL Server stored procedure parse such an object?
>>
>>The reason I am asking is that after reading a few blogs and a chapter in a book on how to build a SaveData method, they all seem to go by processing the entire data set. But in most of the cases that I am working on, it is only one row of the dataset/datatable that is being changed. Therefore, I want to learn how to update the SQL database based on the changes to just one row.
>>
>>TIA.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform