i have two textboxes one for user name and another for
password . i have a table name compare(which contains
name,passwod etc.,)my doubt is how compare username
textbox with name column and how compare password textbox
with passwod column. i want the code
Answer Posted / rahul dabur
//Make a store procedue with name dbologin
Create PROCEDURE dbologin
(
@uid varchar(50),
@Pass varchar(50)
)
AS
declare @pwd varchar(50)
select @pwd=Password from tbllogin where UName=@uid and
Password=@Pass
if @pwd is null
return 1
else if @pwd=@Pass
return 2
//At a button click event with connected approach
protected void btnlogin_Click(object sender, EventArgs e)
{
// string textStr ;
SqlCommand cmd = new SqlCommand("dbologin", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@uid", SqlDbType.VarChar,
50).Value = Convert.ToString(txtusername.Text);
cmd.Parameters.Add("@Pass", SqlDbType.VarChar,
50).Value = Convert.ToString(txtpassword.Text);
// textStr = Convert.ToString(txtpassword.Text);
//textStr = cmd.Parameters.Add("@Pass",
SqlDbType.VarChar, 50).Value.ToString();
// textStr = cmd.Parameters.Add("@Pass",
SqlDbType.VarChar, 50).Value;
SqlParameter p1 = new SqlParameter("@s", SqlDbType.Int);
p1.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(p1);
cmd.ExecuteNonQuery();
Int32 k = Convert.ToInt32(cmd.Parameters["@s"].Value);
if (k == 1)
{
Label1.Text = "Wrong UserName and password";
}
else
{
Label1.Text = "Right UserName and Password";
Response.Redirect("calculator.aspx");
}
cmd.Dispose();
con.Close();
txtusername.Text = string.Empty;
txtpassword.Text = string.Empty;
// Response.Redirect("calculator.aspx");
}
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Define ado.net?
What provider ado.net use by default? Explain the role of data provider in ado.net? What is the role of data provider in ado.net?
Explain what is datagrid with an example?
What is ado.net in vb net?
What is ado code?
How is entity framework different from ado.net?
What is the difference between data grid and data repeater?
What do you know about ado.net's methods?
How to check if the Dataset has records ?
describe the dataset object in ado.net.
How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
Which is faster entity framework or ado.net?
What are the Features and disadvantages of dataset
Why is it important to close an ado.net application?
What does adodb stand for?