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

How do you update a dataset in ado.net?

1003


What are the core objects of ADO.NET?

1027


What are the main differences between classic ado and ado.net?

1011


What are the advantages using ado.net?

1016


What is ado.net and its features?

963


What is the difference between Dataset. clone and Dataset.copy?

1027


What are the different methods by which we can populate a dataset?

1216


What is the difference in record set and dataset?

1014


What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?

1001


Describe datareader object of ado.net with example.

911


Explain how to pass multiple tables in datasets simultaneously?

1015


What is ado.net architecture?

913


What is datasource in ado.net?

1056


Explain what are acid properties?

958


What are the different execute methods of Ado.Net?

1009