|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
TimeStamp field, help neededI get this error: "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." This is my table definition: CREATE TABLE [dbo].[FieldNameXRef] ( [FNXApplication] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [FNXOriginalName] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [FNXSource] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [FNXNewName] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [FNXComment] [varchar] (48) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [FNXTimeStamp] [timestamp] NOT NULL , [FNXSequential] [int] IDENTITY (1, 1) NOT NULL ) ON [PRIMARY] GO And, in the program I have: if ( myDataRow == null ) // If the row was not found, add it to the DataTable { dr = dtFieldNameXRef.NewRow(); // Create new Row in dtFieldNameXRef dr[ "FNXApplication" ] = selectedApp; // Set Comment Field Value dr[ "FNXOriginalName" ] = label; // Set Label Field Value dr[ "FNXSource" ] = name; // Set Source Field Value (filename) dr[ "FNXComment" ] = comment; // Set Comment Field Value dtFieldNameXRef.Rows.Add( dr ); // Add the new Row to the DataTable } Note that in the code shown, I have not initialized the FNXTimeStamp field. I have also tried initializing the FNXTimeStamp field to null, NULL, DB.NULL, new DBNull(), DBNull.Value -- and all produce one error or another. TIA, Jim Holloman Read the error! "or with a default of NULL for the timestamp column."
Therefore change the table definition! "[FNXTimeStamp] [timestamp] NULL ," Show quote "Jim H" <nore***@BellSouth.net> wrote in message news:MPG.1e64545298880858989870@msnews.microsoft.com... >I am attempting to update a Database Table thru a DataAdapter using a >DataSet. > > I get this error: > "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." > > > This is my table definition: > CREATE TABLE [dbo].[FieldNameXRef] ( > [FNXApplication] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT > NULL , > [FNXOriginalName] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT > NULL , > [FNXSource] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL > , > [FNXNewName] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL > , > [FNXComment] [varchar] (48) COLLATE SQL_Latin1_General_CP1_CI_AS NULL > , > [FNXTimeStamp] [timestamp] NOT NULL , > [FNXSequential] [int] IDENTITY (1, 1) NOT NULL > ) ON [PRIMARY] > GO > > > And, in the program I have: > if ( myDataRow == null ) // If the row was not found, add it to the > DataTable > { > dr = dtFieldNameXRef.NewRow(); // Create new Row in > dtFieldNameXRef > > dr[ "FNXApplication" ] = selectedApp; // Set Comment Field Value > dr[ "FNXOriginalName" ] = label; // Set Label Field Value > dr[ "FNXSource" ] = name; // Set Source Field Value > (filename) > dr[ "FNXComment" ] = comment; // Set Comment Field Value > > dtFieldNameXRef.Rows.Add( dr ); // Add the new Row to the DataTable > } > > Note that in the code shown, I have not initialized the FNXTimeStamp > field. I have also tried > initializing the FNXTimeStamp field to null, NULL, DB.NULL, new DBNull(), > DBNull.Value -- and > all produce one error or another. > > TIA, Jim Holloman Thanks, Jim, for the reply.
I made the change to allow "NULL" in the TimeStamp Column and still get the same error. My table now looks like this (as the script generator produces it): CREATE TABLE [dbo].[FieldNameXRef] ( [FNXApplication] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [FNXOriginalName] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [FNXSource] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [FNXNewName] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [FNXComment] [varchar] (48) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [FNXTimeStamp] [timestamp] NULL , [FNXDateTime] [datetime] NULL , [FNXSequential] [int] IDENTITY (1, 1) NOT NULL ) ON [PRIMARY] GO In article <O8RNDFqNGHA.2***@TK2MSFTNGP10.phx.gbl>, NOSPAMJ3033@Hotmail.com says... Show quote > Read the error! "or with a default of NULL for the timestamp column." > > Therefore change the table definition! > "[FNXTimeStamp] [timestamp] NULL ," > > > "Jim H" <nore***@BellSouth.net> wrote in message > news:MPG.1e64545298880858989870@msnews.microsoft.com... > >I am attempting to update a Database Table thru a DataAdapter using a > >DataSet. > > > > I get this error: > > "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." > > > > > > This is my table definition: > > CREATE TABLE [dbo].[FieldNameXRef] ( > > [FNXApplication] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT > > NULL , > > [FNXOriginalName] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT > > NULL , > > [FNXSource] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL > > , > > [FNXNewName] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL > > , > > [FNXComment] [varchar] (48) COLLATE SQL_Latin1_General_CP1_CI_AS NULL > > , > > [FNXTimeStamp] [timestamp] NOT NULL , > > [FNXSequential] [int] IDENTITY (1, 1) NOT NULL > > ) ON [PRIMARY] > > GO > > > > > > And, in the program I have: > > if ( myDataRow == null ) // If the row was not found, add it to the > > DataTable > > { > > dr = dtFieldNameXRef.NewRow(); // Create new Row in > > dtFieldNameXRef > > > > dr[ "FNXApplication" ] = selectedApp; // Set Comment Field Value > > dr[ "FNXOriginalName" ] = label; // Set Label Field Value > > dr[ "FNXSource" ] = name; // Set Source Field Value > > (filename) > > dr[ "FNXComment" ] = comment; // Set Comment Field Value > > > > dtFieldNameXRef.Rows.Add( dr ); // Add the new Row to the DataTable > > } It is apparently a bug. The DataAdapter Wizard generates an InsertCommand property that includes
timestamp columns. See the following Knowledge Base article: http://support.microsoft.com/?kbid=815543 I am surprised to find a glaring bug like this in Visual Studio 2003. The timestamp type is a read-only type. I have VS Ver. 7.1.3088 and ADO.Net Ver. 1.1.4322. I have been unable to understand, or follow, Step 5 of the Resolution, and thus have concluded that I will not be able to use Timestamp columns in my Databases. That, in turn, disrupts my planned approach to concurrency checking. Can someone confirm that this has been fixed in VS2005? Jim Holloman |
|||||||||||||||||||||||