 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Donald S. Bossen Guest
|
Posted: Wed May 02, 2007 10:39 pm Post subject: New to Sql Database's |
|
|
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
|
Posted: Thu May 03, 2007 12:01 am Post subject: Re: New to Sql Database's |
|
|
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
|
Posted: Fri May 04, 2007 8:11 am Post subject: Re: New to Sql Database's |
|
|
| 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 |
|
 |
|
|
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
|
|