Change connection string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a good way to allow the user to change the connection string rather
than allow them access to the actual code? If I use an input box, then it
seems possible that at times that variable would be empty, causing an error.
What's the best way?
 
We handle this by having a table with different connectionstring which can be
select from a combobox.

So we know exactly what they are connecting to. Only an administrator should
be able to add new connectionstrings.
 
I tried that, but then on occasion the connection to the table holding the
connections was broken, causing an error.

I thought this would be so clever:

Conn = "Provider=sqloledb;Data Source= " & strServer & ";Initial catalog= "
& strDB1 & ";Integrated Security=SSPI;"

but if the connection to the provider of the value for strServer is broken,
it's a problem.
 
You could as well hold this in a seperate file.
In .NET you have an application.config or web.config file which is basically
an xml file.
From version .NET 2 you will also be able to encrypt sensitive data in such
an xml file.

So basically i'm telling you to have a seperate file, database which holds
the connection strings. I would also store the complete connectionstring and
wouldn't concatenate it in code because then you can also connect to other
e.g. user/password servers since this can be included in the connectionstring.
 
Back
Top