hi
i am using two textboxes for username and password.
how to match whether this exist in datbase or not through c# code only.
Matching username and password
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Rajkumar Murugesan6 reputationPosted Jan 15, 2006, 5:48 AM EST
CREATE TABLE User(
username varchar(50),
password varchar(50)
)
dim int temp;
SqlConnection con=new SqlConnection(connection String here);
con.open();
SqlCommand cmd=new SqlCommand(SELECT count(*)FROM user WHERE username='
while(dr.Read());
{
temp=Convert.ToInt64(dr[0]);
}
if(temp==0)
{
Response.Redirect("Login.aspx");
}
else
Response.Redirect("Welcome.aspx");
i hope that this will work out...
tom christ11 reputationPosted Jan 15, 2006, 9:09 PM EST
CREATE PROCEDURE Sp_Scheduler_Login
@userName nvarchar(50),@password nvarchar(50)
as
If Exists(select * from tbl_Scheduler_Project where userName=@userName AND password=@password)
Return 1
ELSE
Return 0
GO
and call this stored proc where u want to use.
or
DataSet ds= new DataSet()
fill this ds with the query (select * from tbl_AdminLogin where username = '" + TextBox1.text + "' and pass = '" + TextBox2.Text + "'")
if(ds.Table[0].Count>0)
{
allready exist
}
else
{
new user
}