DataReader not matching strings???!?

Results 1 to 2 of 2

Thread: DataReader not matching strings???!?

  1. #1
    Join Date
    Dec 1969

    Default DataReader not matching strings???!?

    I am trying to create a simple login script that checks the entered username and pass against an SQL Server 2000 dbase. What I do is use the sqlcommand select password from table where username=&#039;whatever&#039;. There will be at most 1 match. I use the datareader.Read() command once, and then I try this:<BR><BR>if( dataReader.GetString(0) == &#039;thepass&#039; )<BR> // give a AuthSuccess event<BR>else<BR> // give a AuthFailure event<BR><BR>the problem is I ALWAYS get an AuthFailure event. For some reason, the dataReader.GetString(0) NEVER matches the text, and I KNOW what the password is (there is only 1 record in the dbase). I am completely dumbfounded as I beleive the logic is completely correct. Any help is definately appreciated.<BR><BR>(NOTE: for example, the username is "test" and the password is "test". even if I hardcode the sqlcommand (select Password from table where Username=&#039;test&#039;), the GetString(0) STILL won&#039;t match. In fact, I can&#039;t get it to match ANYTHING).

  2. #2
    Join Date
    Dec 1969

    Default Try this

    if( dataReader.GetString(0).Equals("thepass") )<BR>...<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts