What data type does the SQLCommand method ExecuteScalar() return?

后端 未结 3 1062
温柔的废话
温柔的废话 2021-01-18 16:08

In SQL Server, ID is a not null integer, and an identity.

When I run the following code, I get an InvalidCastException on the last line:

SqlCommand         


        
3条回答
  •  北海茫月
    2021-01-18 16:23

    From the end of your INSERT statement

    SELECT SCOPE_IDENTITY()
    

    It's returning the identity value of the row inserted into the [Users] table.

提交回复
热议问题