If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Using a UDL in connectionstring

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-04, 13:22
eric2000 eric2000 is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
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!

Thx
Reply With Quote
  #2 (permalink)  
Old 04-19-04, 15:45
eric2000 eric2000 is offline
Registered User
 
Join Date: Mar 2004
Posts: 11
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On