Dynamic loading of password in connection strings?

  • Thread starter Thread starter mfresa
  • Start date Start date
M

mfresa

I'm a newbie to VB.NET, and so far have used the wizard to generate
connection strings to an Oracle database. In the wizard, the userid
and password are hard coded into the connection string. Is there any
way I can get a userid and password from Windows XP registry, or
dynamically load the userid and password at runtime? If so, how does
one reference a variable in the connection string?
Thanks in advance for your help.
Mark
 
Hi Mark
There is no such thing as variable with in the connection string ( not
like the parameters within the command object ) . What you can do; however
, is to get these values at run time form the user ( or what ever source )
then with them construct the connection string .
For example you can say
Dim user_name As string
Dim connection_string as string
' get the value of the user name in the variable user name
' then construct your connection string


Connection_ stirng = " la blasa adf skjlkjlkjlkj username= " & user_name
& " sdfkjlsdjflksdjf "
'once constructed your string , assign it to the connection string of your
connection objct
Myconection.connectionString = connection_string
' then open your connection to do your DB job
Hope this helps

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
Back
Top