Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the disadvantages of using datalist?

988


What are the data providers used in ado.net

986


What is ole access?

894


How can we check that some changes have been made to dataset since it was loaded?

933


What are the various methods provided by the DataSet object to generate XML?

975


What are the namespaces used in ado.net for data access?

940


What is a string variable?

880


How will you fill the gridview by using datatable object at runtime?

994


What are all the different authentication techniques used to connect to MS SQL Server?

1029


Why is ADO.NET serialization slower than ADO ?

1011


What are advantages of microsoft-provided data provider classes in ado.net?

965


Can we do database operations without using any of the ado.net objects?

947


Which object holds only data and does not interact with data source?

927


What is the difference between data reader and data adapter?

979


Which is faster entity framework or ado.net?

893