Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SqlCommandBuilder class
Message
De
14/04/2014 14:20:24
 
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01598513
Message ID:
01598620
Vues:
54
This message has been marked as the solution to the initial question of the thread.
>>Try not setting the adapter.UpdateCommand. See remarks section under http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand%28v=vs.110%29.aspx and the fifth paragraph at http://msdn.microsoft.com/en-us/library/tf579hcz%28v=vs.110%29.aspx for reasons why it shouldn't be set.
>
>If I am not setting it myself, it remains NULL. Do you see what is missing in my code? I populate the adapter by passing SqlCommand.
>
>I moved creating of the builder into the UpdateRows() method, but it was originally in the Populate method and still all the adapter's commands were null.
>
>Adapter is defined as private property of the class.

You are setting it in this line:
adapter.UpdateCommand = builder.GetUpdateCommand(true);
That sets it to a single command that doesn't change. It needs to be left to null so that the command builder hooks into the OnRowUpdating event (see second paragraph under remarks at http://msdn.microsoft.com/en-us/library/System.Data.SqlClient.SqlCommandBuilder%28v=vs.110%29.aspx) and populates it at that time for the row being updated. Based on the example there, you may need to call builder.GetUpdateCommand, but don't assign it to adapter.UpdateCommand.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform