Solved

String Comparison TEdit vs ADOConnection

Posted on 2004-08-11
6
183 Views
Last Modified: 2010-04-05
Hi,

I have to following problem. I have an TEdit password field which needs to check the value from the TEdit field (pwField) with the result from the query. If the two values are exactly the same, go is set to True. The problem is this: the "If pwd = realPwd then" statement always returns False for some reason, even when the values are the same. Can anybody help me out with this?

The Code Snippet:
===========================================
procedure TAfmeldStoring.HelpDeskAfmeldenClick(Sender: TObject);
var
  go : boolean;
  realPwd, pwd: string;
begin
    go := False;
    ADOConnectionA.Close;
    ADOQueryA := TADOQuery.Create(nil);
    ADOQueryA.Connection := ADOConnectionA;
    ADOQueryA.SQL.Text := 'Select password from LUpasswords where application = '+CHR(39)+'MyApp'+CHR(39);
    ADOQueryA.Open;
    pwd := pwField.Text;
    If ADOQueryA.RecordCount<>0 then begin
      realPwd := AdoQueryA.Fields[0].Value;
    end;
    ADOQueryA.Close;
    ADOConnectionA.Close;

    if pwd = realPwd then
      go := True;
end;
0
Comment
Question by:jornv
6 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 11771054
Hi
1. go might not be set because it is local variable and it is not used anywhere.
2. Don't use RecordCount rather Eof and Bof
0
 

Author Comment

by:jornv
ID: 11771066
No, this part:
======
if pwd = realPwd then
      go := True;

will always return false, if the go is locally declared or not that aint the problem, be cause it doesnt even reaches that since it returns false.
0
 
LVL 17

Expert Comment

by:mokule
ID: 11771159
It is a problem
Look at the code below

procedure TForm1.Button1Click(Sender: TObject);
var
  go: boolean;
  s1,s2: string;
begin
  go := False;    // there is no blue dot on the left margin - it is not executed
  s1 := 'x';
  s2 := 'x';
  if s1 = s2 then
    go := True;    // there is no blue dot on the left margin - it is not executed
end;
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 2

Accepted Solution

by:
DarkCore_ earned 50 total points
ID: 11771227
try  go := pwd = realPwd

Edu
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11771378
change the query to :

Select UPPER(password) from LUpasswords

and then the check should be

if UpperCase(pwd) = UpperCase(realPwd) then
      go := True;
0
 

Author Comment

by:jornv
ID: 11771412
Thanks DarkCore_, this is what I needed, it works case sensitive and I dont need to declare a global variable
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question