connection string variable...

B

Brad Pears

We have several applications that use the ".exe.config" .xml file to get
the connection string to our SQL server db. Each user of the application has
their own .xml file because we have some user specific settings in there...

My question is this... We are looking at setting up a backup SQL server. I
would like to modify the .xml config files so that they read the connection
string from a network share instead. That way, we can easily change the
server name in place so that the next time the users run the app, it will be
pointing to the backup server and vice versa.

Does anyone have any ideas how this could be done?

Thanks, Brad
 
M

Mr. Arnold

Brad Pears said:
We have several applications that use the ".exe.config" .xml file to get
the connection string to our SQL server db. Each user of the application
has their own .xml file because we have some user specific settings in
there...

My question is this... We are looking at setting up a backup SQL server.
I would like to modify the .xml config files so that they read the
connection string from a network share instead. That way, we can easily
change the server name in place so that the next time the users run the
app, it will be pointing to the backup server and vice versa.

Does anyone have any ideas how this could be done?

You come-up with a file called connstr.txt and have the connection string in
that file, after all it's just string/text data in a file, whether it's in
an XML file or a non XML text file type.

You create a function that opens that file and reads the string data from
connstr.txt. You can have a path statement in the ".exe.config" .xml
pointing to connstr.txt. Connstr.txt can be out there on a network share.
You're only problem would be if two or more users tried to open Connstr.txt
at the same time.

You may need some code in the function to try again to open the file on some
iteration count, before it indicates it can't open the file. But that's most
likely not going to happen anyway with multiple users trying to open the
file at the same time.
 
B

Brad Pears

So would you write the function separate from the app using vb script (a
..vbs file) and somehow call that from the .xml file (if you can) or would
you code this directly into the application - where we are getting the
config settings now? and just string together the server name with the rest
of the connection string?

Thanks, Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top