Trying to get SELECT SCOPE_IDENTITY() as c# variable
<p>I am inserting a row into one table then want to get that new ID so I can add it in another variable where I have email address stored. </p>

<pre><code> var db = Database.Open("myDB");
 var insertCommand1 = "INSERT INTO myDB (FirstName, LastName) Values(@0, @1)";                       
 db.Execute(insertCommand1, first, last);
 var lastInsertedId = db.QueryValue("SELECT SCOPE_IDENTITY()");

 var insertCommand2 = "INSERT INTO email (id_person, email) Values(@0, @1)";
 db.Execute(insertCommand2, lastInsertId, email);
</code></pre>

<p>where id_person is the id that is created in my first table. When I run the code I get lastInsertedId = {}. Any reason why it is not grabbing a value for id_person which is a primary key, int , not null for my first table? --Tim</p>