enrique_aeo
asked on
retrieve the identity value in my data layer
hi expert, i have this store procedure
create procedure [dbo].[EvaluacionSentencia sJudiciale sInsertar]
(
@tipoDocumento char(1) ,
@numeroDocumento varchar(50) ,
...
)
AS
SET NOCOUNT ON
INSERT INTO [EvaluacionSJ].[dbo].[Eval uacionSent enciasJudi ciales]
([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(ObtenerConex ion());
cmd = new SqlCommand("EvaluacionSent enciasJudi cialesInse rtar", con);
cmd.Parameters.Add("@tipoD ocumento", SqlDbType.Char).Value = ddlTipoDocumento.SelectedI tem.Value;
cmd.Parameters.Add("@numer oDocumento ", SqlDbType.VarChar).Value = txtNumeroDocumento.Text.Tr im();
cmd.Parameters.Add("@condi cionMagist rado", SqlDbType.Char).Value = ddlCondicionMagistrado.Sel ectedItem. Value;
cmd.Parameters.Add("@obsMa nejoJurisp rudencial" , SqlDbType.VarChar).Value = txtManejoJurisprudencial.T ext.Trim() ;
cmd.CommandType = CommandType.StoredProcedur e;
try
{
con.Open();
cmd.ExecuteNonQuery();
LimpiarControles();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}
create procedure [dbo].[EvaluacionSentencia
(
@tipoDocumento char(1) ,
@numeroDocumento varchar(50) ,
...
)
AS
SET NOCOUNT ON
INSERT INTO [EvaluacionSJ].[dbo].[Eval
([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(ObtenerConex
cmd = new SqlCommand("EvaluacionSent
cmd.Parameters.Add("@tipoD
cmd.Parameters.Add("@numer
cmd.Parameters.Add("@condi
cmd.Parameters.Add("@obsMa
cmd.CommandType = CommandType.StoredProcedur
try
{
con.Open();
cmd.ExecuteNonQuery();
LimpiarControles();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}
ASKER
can you give the code to:
make an output parameter and set the value of output parameter in SP and retrieve the same in your C# code
make an output parameter and set the value of output parameter in SP and retrieve the same in your C# code
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
and how to retrieve the value to assign to a text box?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
alternatively, make an output parameter and set the value of output parameter in SP and retrieve the same in your C# code.