Solved

String Comparison TEdit vs ADOConnection

Posted on 2004-08-11
6
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

615 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