<p>Here's a very simple question. I have an SP that inserts a row into a table and at the end there's the statement RETURN @@IDENTITY. What I can't seem to find is a way to retrieve this value in C#. I'm using the Enterprise library and using the method:</p>

<pre><code>db.ExecuteNonQuery(cmd);
</code></pre>

<p>I've tried <strong>cmd.Parameters[0].Value</strong> to get the value but that returns 0 all the time. Any ideas?</p>

```
```
Dim c as new sqlcommand("...")

Dim d As New SqlParameter()
d.Direction = ParameterDirection.ReturnValue
c.parameters.add(d)

c.executeNonQuery

(@@IDENTITY) = d.value
```
```
It is more or less like this...either this or just return the value from a stored procedure as an output parameter.