Is it possible to modify the connection string when using a databound project?
If I specify a datasource for my project, It builds the Connection string. Is it possible to modify this to change the Server name programatically? I am trying to switch over to using databinding in my project, and I would like to be able to specify the Database server name on the initial load of the application.
Re: Is it possible to modify the connection string when using a databound project?
If think that if close all opened connection to bd then you modify at will.
Re: Is it possible to modify the connection string when using a databound project?
Are you saying that you're building a Data Source in the IDE at design time and thus you're using TableAdapters to get your data? If so then each TableAdapter has its own Connection object. You need to go into the DataSet designer, select a TableAdapter and set its ConnectionModifier property to Public. That will allow you to access the Connection property of every TableAdapter in code. You should then create your new connection string in code, probably using the ConnectionStringBuilder class for your data source, then set the Connection.ConnectionString property of each of your TableAdapters. I always declare a SetConnectionStrings method that does just that, which I call from the form's Load event handler.