Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String Comparison TEdit vs ADOConnection

Posted on 2004-08-11
6
Medium Priority
?
189 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
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.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

719 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