SQL Server @@identity Problem

M

Micheal

The below code does _not_ work! The datatype for the autoincrement value is
INT in SQL Server 2000. The strange thing is that if I use a 'decimal' it
works (using .NET framework 1.1)

---------------------------------------------------------
string sql = "insert into sports (name) value ('test'); select @@identity";

conn.Open();

SqlCommand cmd = new SqlCommand(sql, conn);
int result = (int)cmd.ExecuteScalar();
 

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