First create the procedur as follow. . .
ALTER PROCEDURE dbo.loginpro
@email varchar(50),
@pass varchar(50),
@u_id int=0,
@id int=null output
AS
select @u_id=uid from user_reg where uemailid=@email and upass=@pass;
set @id=@u_id
RETURN @id
Then after in button click event. . .
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("loginpro", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@email", TextBox1.Text);
cmd.Parameters.AddWithValue("@pass", TextBox2.Text);
SqlParameter id = cmd.Parameters.Add("@id", SqlDbType.Int);
id.Direction = ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery();
int log = Convert.ToInt32(id.Value);
}
0 comments:
Post a Comment