Get an OUTPUT variable from an Insert SQL statement
Hi,
I have been looking for away to get an output variable from an SQL query, however for SQL Compact Edition.
using (da.InsertCommand = new SqlCeCommand(@"INSERT INTO SCHEMAS (SCHEMA_NAME, FromMethod, ToMethod, ConnectedToUserID) OUTPUT INSERTED.SCHEMA_ID
VALUES (@SchemaName, @FromMethod, @ToMethod, @ConnectedToUserID)", connString))
{
da.InsertCommand.Parameters.AddWithValue("@SchemaName", textBoxSchemaName.Text);
da.InsertCommand.Parameters.AddWithValue("@FromMethod", comboBoxFromMethod.Text);
da.InsertCommand.Parameters.AddWithValue("@ToMethod", comboBoxToMethod.Text);
da.InsertCommand.Parameters.AddWithValue("@ConnectedToUserID", userID);
da.InsertCommand.Connection.Open(); //Needed to open a connection
da.InsertCommand.ExecuteNonQuery(); //Performs the actual SQL statement
this.Close();
}
Can someone please assist my how I can get this output variable out to a C# variable?
Thanks in advance,
Tomas