I want to do a normal INSERT statement from within ASP.NET, and I also want to return the ID that was used for the insertion ..
By the way, the database being used here is Oracle 11g ..
I know that within a stored procedure or a script, you can use something like this to return the ID inserted:
insert into mytable (...) values (...) returning id into v_id;
But since my call is being generated from within ASP.NET, I can't get the returning value.
Also, my due to misc. circumstances, I can't use Stored Procedures, or anything similar ..
Here is my current code:
System.Data.IDbConnection connection = this.CreateConnection();
connection.Open();
strIFRSCostID = taxDetails.Rows[0]["IFRSCOST_ID"].ToString();
strQuery = "INSERT INTO ....";
System.Data.IDbCommand cmd = this.CreateCommand(strQuery);
cmd.Connection = connection;
cmd.ExecuteNonQuery();
connection.Close();
Can I somehow insert AND get the inserted ID using the same command within ASP.NET ?