I'm using C/C++ to access an SQL DB but want to dynamically create the UDL filename depending on whether it is a test or production environment. I can successfully get to the DB when I hard code the UDL (eg. C:\EXE\FILETEST.UDL) but having problems when I'm trying to use a WCHAR variable. I'm actually passing a char* to a function and then converting this char to a wchar using MULTIBYTETOWIDECHAR api.
if (MultiByteToWideChar( CP_ACP, 0, udlString, strlen(udlString)+1,
wideUdl, sizeof(wideUdl)/sizeof(wideUdl[0])) == 0) {
return "ERROR";
}
wcscpy(spCON->ConnectionString, wideUdl);
On the wcscpy, I'm getting an access violation error.
Any hints/help would be appreciated!
Thx