Link to home
Create AccountLog in
Avatar of HPFE455
HPFE455Flag for United States of America

asked on

How to convert LPCTSTR to int data type using VC++

I am trying to store the count returned from the SQLite query, the return value is of type LPCTSTR;
How can I convert CPCTSTR  value to an int data type.

In the code, the below line has the issue.
 int count  = results.fieldValue(0);

wstring sql=  "select  COUNT(*) from table1;

CppSQLite3Query results = dasContextdb_.execQuery(sql.c_str());
while (! results.eof())
{ 
 int count  = results.fieldValue(0); // Error code
results.nextRow();
}

Open in new window

T
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of HPFE455

ASKER

Thanks jkr, Sara for youe help.

After my post, I found a way to resolve the issue as mentioned below.
wstring Val = results.fieldValue(0);
count  =   _wtoi(Val.c_str());