Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NETODBC
I need to connet to database server with different hosts. I will change the host frequently by iteretaing through some data. How can i make the connection string dynamic so that i can change the host name whenever I need.
 
Also the username and password in the connection string is same throughout all hosts.I need to encrypt the username and password in the connection string. Please guide in this too.
Posted 27-Apr-12 3:54am
ebpzr154
Comments
wizardzz at 27-Apr-12 11:37am
   
This will be easier to help with if you provide some code.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The connection string is just a string. It's very simple string manipulation to change the server name in a connection string. I would suggest just putting a known tag in the connection string in place of an actual server name. When you want to change the server name, it's a very simple call to the Replace method on the string to replace the known tag with the server name.
 
As for encrypting the username and password, you don't. You encrypt the entire connection string in your app.config file. Read this[^].
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 480
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 163
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 27 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid