Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004

    Unanswered: Using a UDL in connectionstring

    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!


  2. #2
    Join Date
    Mar 2004
    I got around this by creating different connectionstrings for each environment, not pretty but it works.

    Have another question related to connectionstrings. On my initial call to the database using the UDL file, it is successful. On any subsequent calls, it fails. On the execute statement for my stored procedure, i receive the error: operation not allowed when object is closed. If i use the connectionstring in the following way
    spCOND->ConnectionString = L"driver={sql server};SERVER=SERVERNAME;uid=user;pwd=pwd;Databas e=SampleDB;";
    then everything is fine.
    again, any help would be appreciated! thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts