Identity value not getting updated from .NET

A

Asfar

I am having problem inserting rows in a table with identity column.
One columen is an Id field with identity set to true.
I insert values into the other column and the column with identity set
to true is updated with correct new values.

From the SQl query analyzer if i check the value of @@Identity it has
null value.
I use Select @@Identity from Test1

When i add values from query analyzer @@Identity has correct values.
Here is the simple code that I am trying out.

SqlCommand objCmd = new SqlCommand("INSERT INTO Test1(DEST) VALUES
('Test2')", objConn);

objConn.Open();
objCmd.ExecuteNonQuery();
objConn.Close();

Anyone has ideas as to what the problem might be.

Thanks,
-Asfar
 

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

Top