Change SQL Servers for Application

  • Thread starter Thread starter AMP
  • Start date Start date
A

AMP

I have a small Visual basic.net 2005 application that needs to get data
from SQL servers
How can I make the dataset that uses My.setting.connection, use
differant servers

ie
My Setting.Connection="Data Source=SRV1;Initial Catalog=DB1;Integrated
Security=True

but when used on another site it needs to be

My Setting.Connection="Data Source=CustSRV1;Initial
Catalog=DB1;Integrated Security=True
 
I use a small dialog to allow the user to input their own server and
database names, store the results in an XML file, then recall it as a
variable, something like this

My Setting.Connection="Data Source="+strServer+";Initial
Catalog="+strDB+";Integrated Security=True";
 
The problem with that is the Dataset was generated using the
my.connection string and if you try to change it a below you get an
error of "Read Only"
 
I would recommend not using the visual connection object. Just manually set
the dataset.datasource property to whatever sting you create. The visual
object just boxes you in, particularly if you wish to move your data code
out of the UI layer.
 
Create an alias that points to the desired server. Use the alias in the
ConnectionString as the server/instance name. When you deploy, change the
local alias to point to the desired server...
See Chapter 9.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
Back
Top