Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FieldValue and FieldByName problems

Status
Not open for further replies.

corsair2

IS-IT--Management
Feb 21, 2001
55
GB
I am using Delphi 3 Pro and have developed a program to analyse data from a local Access Db using an SQL Query and a BDE connection.
However, when trying to assign the values of fields returned by the query using FieldValue or FieldByName no data is inserted into the variables e.g.

MyOrderNo := FieldValue[Query.OrderNo];

or

MyOrderNo := FieldByName(Query.OrderNo).AsValue;

The variables have been decalred and are of the right type.

However, if I now add an EditBox to the form and write the contents of the variable to this (with appropriate type-conversion, of course) then suddenly the variable does have the correct contents!
e.g.

MyOrderNo := FieldByName(Query.OrderNo).AsValue;
EditBox1.Text := IntToStr(MyOrderNo);

Note that when stepping through the program line by line, MyOrderNo will now have the correct content.

Any ideas?



 
Howdy,

I think you just may be trying to access the Query component incorrectly. Firsty, (assuming that you've called your Query component - MyQuery) make sure you have either 'MyQuery.Active := True;' or 'MyQuery.Open;' after you set the SQL string. Secondly, to access fields that are returned, try :

MyOrderNo := MyQuery.FieldByName('OrderNo').AsString;

Hope that helps

WB
 
hi,

i think i have a solution for you my friend... pls try this code...

assuming you declare MyOrderNo as Type REAL

MyOrderNo := QueryName.Fieldbyname('OrderNo').asFloat;

thats all !!! notify me wat happend... i'll be glad to find another solution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top