Returning a value after a insert statement
This is the code im running in DotNet:
After execution the var test contains 1. When i run the same sql statement in mssql the result can be seen in the attached image.
I think the 1 comes from the row number, but i need the 441 to be returned into the test variable.
Thanks in advance!
5 Replies
isnt that just a row number?
yea
It is a row number, but i think that is being returned instead of the Key that i want
those methods typically return the number of affected rows, not the row number
Sql should have something like
select LAST_INSERT_ID()
that will get that id for you automatically. Assuming that your connection wasn't terminated and recreated in the meantimeI fixed it, didnt see your replies till now, thanks anyway!