Hey, there are many things that are wrong and need updating, so I will lead you through it:
conjds.ConnectionString = ConfigurationManager.ConnectionStrings["maillog"].ToString();
conjds.Open();
cmdjds.Connection = conjds;
//-----------
//This below command is wrong because you are selected everything
//from the database, including all 60,000 rows if you have that many users.
//cmdjds.CommandText = "Select * from login ";
//Below line might need changing depending on your column names
cmdjds.CommandText = "SELECT userpass, clientid FROM login WHERE username=@username"
//Parameters help prevent against SQL injection. I would recommend them.
cmdjds.Parameters.AddWithValue( "@username", Trim(username.Text) )
//-----------
//-----------
//This below command doesn't return any rows. It is only used for
//updates, deletes, and inserts. It does return one value, the number
//of records it affected.
//cmdjds.ExecuteNonQuery();
//The above line actually wasn't needed at all, and did nothing. The
//below line (reader) is what does it all.
redjds = cmdjds.ExecuteReader();
//-----------
//-----------
//For using the while read command, it will do whatever is in between
//the brackets for as many rows as you return. If you for some reason
//return 4 rows, it will set those variables 4 times, overwriting it every time.
//A fix for this is to limit the amount of rows returned:
//"SELECT TOP 1 userpass, clientid FROM login WHERE..."
//That will only select 1 row.
while (redjds.Read())
{
login1 = redjds.GetString(0);
pass2 = redjds.GetString(1);
client1 = redjds.GetString(2);
}
//this line fails in a few aspects. C#, much like javascript, uses one single
//equal sign to assign values. You are basically assigning username.Text to
//the login username retrieved from the database, same with the rest
//accordingly. For c#, you use two equal signs to do a logical test. Also, for
//variables that you assign values to (login1, pass2, client1, etc.), you never
//put quotes around. client1 = "a database value", "client1" = "client1"
//Keep in mind, this below line also doesn't compare case-senitivity. The password
//"jerryspringer" will pass validation even though the actual database password is
//"JerrySpringer". To compare case-sensitivity, use the string.equal or string.compare
//methods. Look them up on microsoft.com (google: site:microsoft.com string.compare)
//if (username.Text = "login1" && pass.Text = "pass2" && clientid.Text = "client1" )
if (username.Text == login1 && pass.Text == pass2 && clientid.Text == client1)
{
Response.Redirect("~/assign.aspx");
}
else
{
Response.Write("wrong");
} Hope I helped and gave you insight.
Last edited by SheSaidImaPregy; Feb 14th, 2008 at 11:15 am.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
Offline 1,080 posts
since Sep 2007