|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to compare strings in c#?
<i><b>Originally posted by : kamp (kamph@netease.com)</b></i><br />i want compare user's password and the password from a database(m$sql), but it doesn't work!<br />when i print both two password on the web-browser, they are the same! The following is my code:<br /> <br /> SQLConnection myConnection = new SQLConnection("server=Qacomputer;uid=sa;pwd=;database=sn");<br /> SQLCommand myCommand = new SQLCommand("select psswrd from login where name='"+idname.SelectedItem.Value+"'", myConnection);<br /><br /> myConnection.Open();<br /> myCommand.Execute(out MyReader);<br /> MyReader.Read();<br /><br /> if(MyReader["psswrd"].ToString().Equals(password.Text.ToString()))<br /> hell.Text = "password is corrected";<br /> else<br /> hell.Text = "password is not corrected " +MyReader["psswrd"].ToString() + " " + password.Text.ToString();<br /> MyReader.Close();<br /> myConnection.Close();<br />
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : Doug Seven (doug.seven@codejunkies.net)</b></i><br /><br />Try<br />if(MyReader["psswrd"].ToString()==(password.Text.ToString()))<br /><br />Doug Seven<br />CodeJunkies.Net / ASPNextGen.com<br />------------<br />kamp at 11/9/2000 5:31:12 AM<br /><br />i want compare user's password and the password from a database(m$sql), but it doesn't work!<br />when i print both two password on the web-browser, they are the same! The following is my code:<br /> <br /> SQLConnection myConnection = new SQLConnection("server=Qacomputer;uid=sa;pwd=;database=sn");<br /> SQLCommand myCommand = new SQLCommand("select psswrd from login where name='"+idname.SelectedItem.Value+"'", myConnection);<br /><br /> myConnection.Open();<br /> myCommand.Execute(out MyReader);<br /> MyReader.Read();<br /><br /> if(MyReader["psswrd"].ToString().Equals(password.Text.ToString()))<br /> hell.Text = "password is corrected";<br /> else<br /> hell.Text = "password is not corrected " +MyReader["psswrd"].ToString() + " " + password.Text.ToString();<br /> MyReader.Close();<br /> myConnection.Close();<br />
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > How to compare strings in c#? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|