hi expert, i have this store procedure
create procedure [dbo].[EvaluacionSentenciasJudicialesInsertar]
(
@tipoDocumento char(1) ,
@numeroDocumento varchar(50) ,
...
)
AS
SET NOCOUNT ON
INSERT INTO [EvaluacionSJ].[dbo].[EvaluacionSentenciasJudiciales]
([tipoDocumento]
,[numeroDocumento]
...
VALUES
(
@tipoDocumento
,@numeroDocumento
...
)
select @@IDENTITY
as I can do to get this code (@ @ identity) in my data layer. net?
this i my code in .net
protected void btnSave_Click(object sender, EventArgs e)
{
con = new SqlConnection(ObtenerConexion());
cmd = new SqlCommand("EvaluacionSentenciasJudicialesInsertar", con);
cmd.Parameters.Add("@tipoDocumento", SqlDbType.Char).Value = ddlTipoDocumento.SelectedItem.Value;
cmd.Parameters.Add("@numeroDocumento", SqlDbType.VarChar).Value = txtNumeroDocumento.Text.Trim();
cmd.Parameters.Add("@condicionMagistrado", SqlDbType.Char).Value = ddlCondicionMagistrado.SelectedItem.Value;
cmd.Parameters.Add("@obsManejoJurisprudencial", SqlDbType.VarChar).Value = txtManejoJurisprudencial.Text.Trim();
cmd.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
cmd.ExecuteNonQuery();
LimpiarControles();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}
alternatively, make an output parameter and set the value of output parameter in SP and retrieve the same in your C# code.