Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SqlCommandBuilder class
Message
De
14/04/2014 14:53:43
 
 
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:
01598629
Vues:
23
This message has been marked as a message which has helped 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.
>
>Do you think I don't really need the OnRowUpdating method handler? I only added it to check the command.

You shouldn't need it. I just had you add it for debugging.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform