connectionString

xswzaq

Well-known member
Joined
Jul 9, 2007
Messages
61
Programming Experience
Beginner
is there a way to change connectionString? When I use Data Source Configuration Wizard, it ask me to create a connectionString. I create one (datasource = serve1; user id = xxxx; password = xxxx;....), and now I want to use different connectionString ((datasource = serve2; user id = xxxx; password = xxxx;...) or (datasource = serve3; user id = xxxx; password = xxxx;...)). I want everything on on the form stay the same, but now the connectionString is change to different one. I don't want to re-do all my program, so I think that changing the ConnectionString should be my best solution. Is this possible to do? Thank you for all replies.
 
Last edited:
If you look through the generated code you will see how this is done by default. It's the TableAdapter that uses the connection, so you can simply assign a new connection to it, example:
VB.NET:
Expand Collapse Copy
Table1TableAdapter.Connection = New SqlClient.SqlConnection("the new connection string")
Then you have to fill the Dataset with data from other server, example:
VB.NET:
Expand Collapse Copy
Me.Table1TableAdapter.Fill(Me.NewdatabaseDataSet.Table1)
 
Back
Top