Generating Record ID Key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to insert data from a dataset into the source database. I get an
error when calling update on the data adapter. Here is the error:

Cannot insert the value NULL into column 'KeyID', table 'dbo.Reservations';
column does not allow nulls. INSERT fails.

KeyID is an autogenerated number in SQL Server.

Thanks, Justin.
 
May be you could list out the insert statement, if you don't mind, and also
your table structure, so that anybody else could help,
t
 
Justin,

You must not specify autogenerated number columns in insert statements.

Eliyahu
 
Here is the Insert statement I am using:

this.sqlInsertCommand1.CommandText = @"SET IDENTITY_INSERT Reservations ON
INSERT INTO Reservations(KeyID, EventID, Email, qntyChild, qntyAdult,
qntySenior, GroupID, Status) VALUES (@Identity, @EventID, @Email, @qntyChild,
@qntyAdult, @qntySenior, @GroupID, @Status); SELECT KeyID, EventID, Email,
qntyChild, qntyAdult, qntySenior, GroupID, Status FROM Reservations WHERE
(KeyID = @IDENTITY)";
 
Let me make a wild guess here, your @Identity is no associate to an
appropriate value.

wei chung
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top