Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Programmatically set UID & PWD in existing ODBC DSN connection string.

I am trying to programmatically set the userid (UID) and password
(PWD) in an existing ODBC DSN connection string. I am able to set the
UID but not the PWD. The CURRENT UID is TestID and there is no current
PWD specified. Here is the connection string as it is before I try to
change it:
"ODBC;DSN=SDW_PRD_ALLVM;UID=TestID;;DATABASE=SDW_P RD_ALLVM;"

I am setting the new connection string (TargetConString) from 4
different string variables using the following 2 lines of code...
(The first line builds the new connection string and the 2nd line sets
it. The UID of the new connection string should be "NEWID" and the
password should be "NEWPW")
TargetConString = "ODBC;DSN=" & TDDatabase & ";UID=" & UserName &
";PWD=" & PW & ";DATABASE=" & TDDatabase & ";"

TargetFile.Connections.Item(Counter).ODBCConnectio n.Connection =
TargetConString

However here is the result:
"ODBC;DSN=SDW_PRD_ALLVM;UID=NEWID;;DATABASE=SDW_PR D_ALLVM;"

It sets everything except the PWD where it is still showing a as
blank.

How do I fix this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Programmatically set UID & PWD in existing ODBC DSN connection string.

Well I think I figured it out. This seems to be a glitch somehow...
After thinking a little more about this and looking at other
properties, I noticed a property called SavePassword under the
ODBCConnection. It was set to false. I was looking at the actual
Connection string when I executed the following code to set the
SavePassword property to TRUE:
TargetFile.Connections.Item(Counter).ODBCConnectio n.SavePassword =
True

When I executed the above line, I saw the password that I have been
repeatedly attempting to set suddenly pop into the connection string.
This is odd because I thought the SavePassword property was to PREVENT
the password from being SAVED in the connection string for security
purposes (which makes sense if that were the case). I didnt think it
would prevent a password from being SET. Well apparently this is the
case, but even more perplexing is if it does prevent a password from
being set, then how did it KNOW what password it just PREVENTED from
being set in the first place? In order for the simple action of
setting the SavePassword property to TRUE causes the previously
attempted but prevented password to magically appear in the connection
string, then where is that "prevented" password value even stored? I
sure cant find it, and I dont see any hints of this in any
documenation. I couldnt see it in the definition of the connection or
in any connection or query settings, and I didnt see it in any
property anywhere in the connection...

Am I missing something here?

Thanks
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL ODBC Connection Bythsx-Addagio[_2_] Excel Programming 1 February 24th 09 08:51 PM
ODBC Connection Kezzemil Excel Programming 0 October 6th 06 09:15 AM
ODBC connection string Excel to AS/400 [email protected] Excel Programming 4 September 19th 06 09:57 PM
ODBC Connection Adrian T[_4_] Excel Programming 4 January 25th 05 08:55 PM
ODBC connection by udl Dorothy[_4_] Excel Programming 1 January 8th 04 05:32 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"