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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am creating a database applicatio

Status
Not open for further replies.

csbrmg

Programmer
Jul 1, 2003
9
ZA
I am creating a database application with a sql server backend,but i seem to have a problem extracting an integer Field(size=8) from the database.when using the code
var
q:Tsqlquery;
TID:Integer;
begin
.......
TID:=(q.Fields[0].asinteger);
...
end;
The code works fine for Delwhen the value queried from the db is a string but when the value is an integer the field value when viewed as an integer is 0 and a null string when viewed as a variant
 
You might want to try:
TID := StrToIntDef(q.Fields[0].AsString,0);

The second parameter is the default value you want if the first parameter is not an integer.

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top