Specific cast is not valid, while retrieving scope_identity

Posted by coure06 on Stack Overflow See other posts from Stack Overflow or by coure06
Published on 2010-06-12T06:34:47Z Indexed on 2010/06/12 6:42 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

I am getting exception: "Specific cast is not valid", here is the code

con.Open();
string insertQuery = @"Insert into Tender (Name, Name1, Name2) values ('Val1','Val2','Val3');Select Scope_Identity();";

SqlCommand cmd = new SqlCommand(insertQuery, con);
cmd.ExecuteNonQuery();
tenderId = (int)cmd.ExecuteScalar();

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET