Click here to Skip to main content
15,879,326 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConnection String Couldn't Connect Pin
Brennan Salibrici15-Mar-18 10:17
Brennan Salibrici15-Mar-18 10:17 
AnswerRe: Connection String Couldn't Connect Pin
Gerry Schmitz15-Mar-18 11:01
mveGerry Schmitz15-Mar-18 11:01 
AnswerRe: Connection String Couldn't Connect Pin
Victor Nijegorodov15-Mar-18 11:25
Victor Nijegorodov15-Mar-18 11:25 
GeneralRe: Connection String Couldn't Connect Pin
leon de boer15-Mar-18 17:12
leon de boer15-Mar-18 17:12 
GeneralRe: Connection String Couldn't Connect Pin
Jochen Arndt15-Mar-18 22:10
professionalJochen Arndt15-Mar-18 22:10 
GeneralRe: Connection String Couldn't Connect Pin
Victor Nijegorodov16-Mar-18 8:41
Victor Nijegorodov16-Mar-18 8:41 
GeneralRe: Connection String Couldn't Connect Pin
leon de boer18-Mar-18 4:20
leon de boer18-Mar-18 4:20 
AnswerRe: Connection String Couldn't Connect Pin
leon de boer15-Mar-18 16:49
leon de boer15-Mar-18 16:49 
Put a debug point jsut after this line and look at string
Quote:
SQLWCHAR* strSQL = (SQLWCHAR*)"SELECT Exchanges.[X Name], Exchanges.[X Full Name] FROM Exchanges;";

I am betting it comes out as garbage

Why... this code sequence below is a text string of char AKA 8 bits
Quote:
"SELECT Exchanges.[X Name], Exchanges.[X Full Name] FROM Exchanges;"

I am betting that SQLWCHAR is a wide character AKA something that isn't 8 bits and you just forcibly typecast it.
I am guessing you have to forcibly typecast it because the compiler objected to you assigning it.

You need to do a quick update reading on how to write wide and unicode strings in C/C++
Working with Strings (Windows)[^]

I am guessing that text needed to be .. the L at the start is very important Smile | :)
Quote:
L"SELECT Exchanges.[X Name], Exchanges.[X Full Name] FROM Exchanges;"

Coming off VB you will have an issue that C++ won't hold your hand, strings are not held in both formats like they are in VB because it's slow and costs time and space. VB looks at which of the various forms it matches and will use that right one. There is a class in C++ that acts much like VB strings called CString which carries the strings in both form if you need training wheels, you could use it.

The other option is to become familar with #include <tchar.h> and the features it offers but don't mix it with CStrings if you go that path.

There are other bits that look suspiciously like you have forced typecast probably to get over a compiler error
I am looking at  =====> (wchar_t*)dsnName

Go thru and work out what needs to be char and what needs to be wchar and write the constant strings in the correct form Smile | :)
In vino veritas


modified 15-Mar-18 23:19pm.

GeneralRe: Connection String Couldn't Connect Pin
Brennan Salibrici16-Mar-18 2:45
Brennan Salibrici16-Mar-18 2:45 
QuestionRe: Connection String Couldn't Connect Pin
David Crow16-Mar-18 16:43
David Crow16-Mar-18 16:43 
Questionproblem in operator overloading of >> & << ? Pin
Tarun Jha15-Mar-18 7:47
Tarun Jha15-Mar-18 7:47 
AnswerRe: problem in operator overloading of >> & << ? Pin
CPallini15-Mar-18 10:47
mveCPallini15-Mar-18 10:47 
QuestionCan we include two Message Maps in one class? Pin
Sampath57914-Mar-18 23:23
Sampath57914-Mar-18 23:23 
AnswerRe: Can we include two Message Maps in one class? Pin
Richard MacCutchan14-Mar-18 23:32
mveRichard MacCutchan14-Mar-18 23:32 
GeneralRe: Can we include two Message Maps in one class? Pin
Sampath57914-Mar-18 23:39
Sampath57914-Mar-18 23:39 
AnswerRe: Can we include two Message Maps in one class? Pin
Jochen Arndt15-Mar-18 0:53
professionalJochen Arndt15-Mar-18 0:53 
GeneralRe: Can we include two Message Maps in one class? Pin
Sampath57915-Mar-18 1:08
Sampath57915-Mar-18 1:08 
GeneralRe: Can we include two Message Maps in one class? Pin
Sampath57915-Mar-18 4:19
Sampath57915-Mar-18 4:19 
GeneralRe: Can we include two Message Maps in one class? Pin
Victor Nijegorodov15-Mar-18 4:48
Victor Nijegorodov15-Mar-18 4:48 
GeneralRe: Can we include two Message Maps in one class? Pin
Sampath57915-Mar-18 6:25
Sampath57915-Mar-18 6:25 
GeneralRe: Can we include two Message Maps in one class? Pin
Jochen Arndt15-Mar-18 4:50
professionalJochen Arndt15-Mar-18 4:50 
GeneralRe: Can we include two Message Maps in one class? Pin
Sampath57915-Mar-18 6:57
Sampath57915-Mar-18 6:57 
GeneralRe: Can we include two Message Maps in one class? Pin
Richard MacCutchan15-Mar-18 7:11
mveRichard MacCutchan15-Mar-18 7:11 
GeneralRe: Can we include two Message Maps in one class? Pin
Sampath57915-Mar-18 7:31
Sampath57915-Mar-18 7:31 
GeneralRe: Can we include two Message Maps in one class? Pin
Richard MacCutchan15-Mar-18 8:03
mveRichard MacCutchan15-Mar-18 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.