Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

String Comparison TEdit vs ADOConnection

Posted on 2004-08-11
6
Medium Priority
?
192 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
DarkCore_ earned 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 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