Avatar of HPFE455
HPFE455
Flag 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
C++Visual C++.NET

Avatar of undefined
Last Comment
HPFE455

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jkr

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
sarabande

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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());
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck