The CommandBuilder object may rebuild a command that you try to modify during the next call to the DataAdapter.Update method and your changes to the command may be lost (310366)
The information in this article applies to:
- Microsoft ADO.Net 2.0
- Microsoft ADO.NET (included with the .NET Framework)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic 2005
This article was previously published under Q310366
This article refers to the following Microsoft .NET Framework Class Library namespace:
SYMPTOMS
The CommandBuilder object may rebuild a command that you try to modify during the next call to the DataAdapter.Update method, and your changes to the command may be lost. This problem occurs under the following circumstances:
- If you associate a CommandBuilder object with a DataAdapter object.
- If you use the GetInsertCommand, GetUpdateCommand, or GetDeleteCommand method of the CommandBuilder object to explicitly assign commands to the DataAdapter.
- If you modify one of the commands that CommandBuilder generates.
When you try to call the Update method of the DataAdapter, you may receive the following error message:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
CAUSE
This problem occurs because CommandBuilder dynamically alters the commands that it generates back to the original command.
RESOLUTION
Use one of the following methods to resolve this problem:
- Do not modify commands that CommandBuilder generates. CommandBuilder does not alter Command objects that you build yourself.
- Copy the InsertCommand, DeleteCommand, and UpdateCommand objects to a new DataAdapter (see the "More Information" section for an example). The new DataAdapter variable must have the same scope or narrower as the old DataAdapter variable.
- Do not use CommandBuilder at all. Write your own Command objects, or use Visual Data Tools to write them.
STATUSThis behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbtshoot kberrmsg kbprb kbSqlClient kbSystemData KB310366 kbAudDeveloper |
---|
|