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

How can I assign a SQL value to a c++ variable??

Status
Not open for further replies.

LastCyborg

Programmer
Feb 7, 2003
256
MX
I have a sql string in a query
the sql statement is very simple, is a select count(*)
etc etc, and I want to assing to a variable this number (the result of the sql)

There are many ways to get the number of records in a table, but I'm interested in this method, so if anyone knows please help me
 
I suppose you know how to manage databases in c++ builder,
otherwise read my faq (see the faq tab )

change your query to f.i.

select count(*) as total

suppose that Query1 is your query component

to get the result :

int t=Query1->FieldByName("total")->AsInteger;
Wim Vanherp
Wim.Vanherp@belgacom.net
 
I can put a sql result in a variable finally

thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top