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

Re: Identity value not getting updated from .NET by Earl

Earl
Mon Oct 25 17:30:05 CDT 2004

You'll still have to do a Select if you are need the new Identity values.

"Asfar" <asfars@gmail.com> wrote in message
news:3ce837df.0410251408.4268bcb7@posting.google.com...
>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