Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 ADO MS-Access C++/MFC
Hi Guys,
 
I am facing a weird problem to put the database query in CString Format with
Unicode defined.
 
I am giving a simple example of my problem.
CString str1;
int value = 123;        
str1.Format(_T("select * from Table Where Max > %d"), value);
Getting output only 1st character of entire string.
Output-> "s"  
instead of -> "select * from Table Where Max > 123"
 
I also tried this one but It's not getting integer variable and displaying like this:
str1.Format((LPCTSTR)("select * from Table Where Max > %d"), value);
OutPut-> "select * from Table Where Max > %d"
 
Please give me some solution because I tried everything but I didn't get where I did
mistake.
Posted 10-Jul-12 5:00am
Edited 10-Jul-12 5:05am
v2
Comments
nv3 at 10-Jul-12 10:45am
   
I'd check two things:
 
Is str1 defined as CString or CStringA or CStringY?
 
Is UNICODE and _UNICODE defined?
 
The latter problem would be my guess, so the Windows headers think they compile for Unicode and MFC headers think they compile of MBCX and hence select the wrong library.
saqib.akhter at 10-Jul-12 11:04am
   
Thanks for reply..
but I got a solution that unicode display string setting was not enable that's why it happened.
 
Thanks for your investigation that could also help me in future...

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I got solved myself actually I just did silly mistake.
There is a one unicode setting has to be enable in Visual Studio.
 
Here is the solution:
 
Check the following setting in Visual Studio:
Tools->Options->Debug
Check Display unicode strings checkbox.
 
Thanks...
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 10 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100