BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New to Sql Database's

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Donald S. Bossen
Guest





PostPosted: Wed May 02, 2007 10:39 pm    Post subject: New to Sql Database's Reply with quote



I am New to Sql Databases. Is there a better way to to the following.

DataSetCustomer.Active := False;
DataSetCustomer.CommandText := 'select Customer_Name,'
+' customer_id'
+' from p21_view_customer'
+' where customer_id =
'+FldCustNo.Text;
DataSetCustomer.Active := True;
if
DataSetCustomer.Locate('customer_id',FldCustNo.Text,[loCaseInsensitive])
then
begin
FldCustName.Caption :=
DataSetCustomer.FieldByName('Customer_Name').AsString;
ect.
This works but seams A little awkward.
Using Delphi6,and a ADODataSet.
Thanks
Donald S. Bossen
Back to top
Brian Hollister
Guest





PostPosted: Thu May 03, 2007 12:01 am    Post subject: Re: New to Sql Database's Reply with quote



From the looks of your code there is no need to do the locate. You query is
very selective and should only return one record anyway. After the open you
can just assign the Caption property...

brian
--
Got a big event coming up? Let us
help coordinate your event. For more
visit www.kissemgoodbye.com
"Donald S. Bossen" <sbossen (AT) jbimporters (DOT) com> wrote in message
news:4638ccbd$1 (AT) newsgroups (DOT) borland.com...
Quote:
I am New to Sql Databases. Is there a better way to to the following.

DataSetCustomer.Active := False;
DataSetCustomer.CommandText := 'select Customer_Name,'
+' customer_id'
+' from p21_view_customer'
+' where customer_id =
'+FldCustNo.Text;
DataSetCustomer.Active := True;
if
DataSetCustomer.Locate('customer_id',FldCustNo.Text,[loCaseInsensitive])
then
begin
FldCustName.Caption :=
DataSetCustomer.FieldByName('Customer_Name').AsString;
ect.
This works but seams A little awkward.
Using Delphi6,and a ADODataSet.
Thanks
Donald S. Bossen

Back to top
Brian Bushay TeamB
Guest





PostPosted: Fri May 04, 2007 8:11 am    Post subject: Re: New to Sql Database's Reply with quote



Quote:
From the looks of your code there is no need to do the locate. You query is
very selective and should only return one record anyway. After the open you
can just assign the Caption property...

My guess is he is trying to eliminate a query that returns no records.
If DataSetCustomer.RecordCount >0 then

Would handle that a bit more elegantly
--
Brian Bushay (TeamB)
Bbushay (AT) NMPLS (DOT) com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.