BUG: The DataAdapter Wizard generates an InsertCommand property that includes timestamp columns (815543)
The information in this article applies to:
- Microsoft ADO.NET (included with the .NET Framework) 1.0
- Microsoft ADO.NET (included with the Windows .NET Framework 1.1)
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
Beta InformationThis article discusses a Beta release of a Microsoft
product. The information in this article is provided as-is and is subject to
change without notice.
No formal product support is available from
Microsoft for this Beta product. For information about how to obtain support
for a Beta release, see the documentation that is included with the Beta
product files, or check the Web location where you downloaded the
release.SYMPTOMSWhen you have a timestamp column in the query of the DataAdapter Wizard, the timestamp column is included in the InsertCommand property of the DataAdapter object, and you receive the following error
message: System.Data.SqlClient.SqlException: Cannot insert
a non-null value into a timestamp column. Use INSERT with a column list or with
a default of NULL for the timestamp column." The DataAdapter Wizard
uses OLE DB or Microsoft SQL Client .NET Data Providers. Although the timestamp columns are read-only columns in the table, you notice that the CommandText property in the InsertCommand property is the following: INSERT INTO Tablename(column,
timestampcolumn) VALUES (@column, @timestampcolumn); SELECT column,
timestampcolumn FROM Tablename CAUSEtimestamp columns are read-only columns of the table, and the values in
each row of the timestamp column are unique. When the DataAdapter object connects to the Database through the Data Providers to run
a set of commands, the columns in a table that cannot be updated or be inserted
are marked as read-only by the Data Providers and are not included in the InsertCommand property or the UpdateCommand property of the DataAdapter object. But the timestamp columns are not marked as read-only by the .NET Data Providers in
the DataAdapter object. Therefore, the InsertCommand property includes the timestamp columns. RESOLUTIONTo work around this problem, remove the timestamp column from the CommandText property of the InsertCommand property of the DataAdapter object. To do this, follow these steps:
- In Design View of the Form1 form in a Microsoft Visual
Studio .NET project, right-click the SqlDataAdapter1 control,
and then click Properties.
- In the Properties window, locate the
InsertCommand property.
- Select CommandText in the
InsertCommand property, and remove the tstamp
column from the insertSql query
- In the Do you want to regenerate the Parameters
collection for this command? dialog box, click
Yes.
- In the Source column information for some
parameters may be lost. Do you want to apply new parameter
configuration? dialog box, click Yes.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed in the "Applies to" section of this
article.REFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
Modification Type: | Minor | Last Reviewed: | 3/9/2006 |
---|
Keywords: | kbvs2002sp1sweep kbpending kbWindowsForms kbSSExplorer kbSqlClient kbProvider kbDataObject kbDataLoader kbDataBinding kbDatabase kbDataAdapter kbbug KB815543 kbAudDeveloper |
---|
|