Al termine della mia SP, mi faccio ritornare un valore tramite il seguente codice
codice:
SELECT @IdProvvInserted = @@IDENTITY
Ho quindi la necessità di farmi ritornare nel codice questo valore. Come posso fare?
Il codice che esegue la SP è il seguente
codice:
SqlConnection objSqlConnectionInsert = new SqlConnection(connectionString);
objSqlConnectionInsert.Open();
SqlCommand objSqlCommandSPInsert = new SqlCommand("[dbo].[sp_InsertProvUni]", objSqlConnectionInsert);
objSqlCommandSPInsert.CommandType = CommandType.StoredProcedure;
objSqlCommandSPInsert.Parameters.AddWithValue("@NORMA_NUMERO", numero_norma);
objSqlCommandSPInsert.Parameters.AddWithValue("@ANNO", anno);
objSqlCommandSPInsert.Parameters.AddWithValue("@DATA", Data);
objSqlCommandSPInsert.Parameters.AddWithValue("@ICS", CodiceICS);
objSqlCommandSPInsert.Parameters.AddWithValue("@TITOLO", Titolo);
objSqlCommandSPInsert.Parameters.AddWithValue("@IDTIPOPROV", IdTipoProv);
objSqlCommandSPInsert.ExecuteNonQuery();
objSqlCommandSPInsert.Dispose();
objSqlConnectionInsert.Close();