I'm doing a web application with the ASP.Net C # language but I'm validating the OUT
output to show me the error message:
This is my procedure:
ALTER PROCEDURE pAdminUsersEvaSmart @tipo INT
,@UserName VARCHAR(100)
,@ERROR VARCHAR(100) OUT
AS
BEGIN
IF @tipo = 0
BEGIN
IF EXISTS (
SELECT *
FROM seguridad..Usuario
WHERE username = @UserName
)
BEGIN
UPDATE seguridad..Usuario
SET IntentosUltimoAcceso = 0
,IntentosActualAcceso = 0
,Conexion = 'DES'
WHERE UserName = @UserName
SET @ERROR = 'SE DESBLOQUEO CORRECTAMENTE..'
END
ELSE
BEGIN
SET @ERROR = 'NO SE PUEDE DESBLOQUEAR EL USUARIO NO EXISTE..'
END
END
END
ASP.Net Code:
protected void btnDesbloqueo_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server=10.0.101.85\instbdd01;Database=Seguridad;User Id=sa;Password=SA123456789*;");
SqlCommand cmd = new SqlCommand("pAdminUsersEvaSmart", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@tipo", SqlDbType.Int);
cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 100);
cmd.Parameters.Add("@ERROR", SqlDbType.Char, 500);
cmd.Parameters["@tipo"].Value = 0;
cmd.Parameters["@UserName"].Value = txtUserName.Text;
cmd.Parameters["@ERROR"].Direction = ParameterDirection.Output;
conn.Open();
cargardatos();
cmd.ExecuteNonQuery();
conn.Close();
Label1.Text = cmd.Parameters["@ERROR"].Value.ToString(); ;
if (Label1.Text == "SE DESBLOQUEO CORRECTAMENTE..")
{
ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", "showmodalpopup1();", true);
}
else if (Label1.Text == "NO SE PUEDE DESBLOQUEAR EL USUARIO NO EXISTE..")
{
ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", "showmodalpopup();", true);
}
}
As you can see if it has the same name by which you should enter that if
but do not enter I do not understand why they are the same chains.