Here is a very simple question. I have an SP that inserts a row into the table, and at the end the RETURN @@ IDENTITY statement appears. What I cannot find is a way to get this value in C #. I use the Enterprise library and use the method:
db.ExecuteNonQuery(cmd);
I tried cmd.Parameters [0] .Value to get a value, but which returns 0 all the time. Any ideas?
Dim c as new sqlcommand("...") Dim d As New SqlParameter() d.Direction = ParameterDirection.ReturnValue c.parameters.add(d) c.executeNonQuery (@@IDENTITY) = d.value
It more or less looks like this ... either this, or simply return the value from the stored procedure as an output parameter.
, SCOPE_IDENTITY(), @@IDENTITY. .
. SCOPE_IDENTITY, INSERT. , @@IDENTITY . , TRIGGERS , INSERT.
. Books Online.
- ,
IDENT_CURRENT ( 'TableName')
http://www.velocityreviews.com/forums/t303448-return-identity-after-sql-insert.html
-Zubair http://zubairdotnet.blogspot.com
,
SqlCommand.ExecuteScalar()
, , SCOPE_IDENTITY() , @@IDENTITY
Source: https://habr.com/ru/post/1698858/More articles:How do you balance the design of Framework / API and TDD - c #Export SQL Database to Access - ASP.NET - sqlSQL for Linq expression? - sql-serverC ++ class friend - c ++Are only the relevant ConnectionState enumeration values ββopen and closed? - .netHow to programmatically (in vbscript) change / set the tcp port for a site under IIS? - iisRun index.php, not listing files - apacheIs SPRING.Net the best foundation for aspect-oriented programming (AOP)? - .netHow do you create rDoc for a specific plugin using rake - ruby ββ| fooobar.comHow to gracefully check if Gravatar or a third-party website is working or not? - c #All Articles