I have a c# generated dataset. How can I change the connection string so I can use the dataset with another (identically structured yet differently populated) database? This has to occur at runtime as I do not know the server or database name at compile time. I am using c# 2.0.
Right click your project > Properties > Settings. You can then change connection string. For best results, you can first open file app. config (for non-web projects) and modify your connection string.
In the Properties window, expand the Connection node. To quickly modify the connection string, edit the ConnectionString property, or click the down arrow on the Connection property and choose New Connection.
Start by creating a new project in Visual Studio 2010, for C#. Name the project ConnectionStringSample . Then we will add the datasource to the application. For our example application, we will work with NorthWind sample database for SQL Server, but for any other database the procedure will be the same.
You can modify a single instance of the table adapter.
_myAdapter.Connection.ConnectionString = connectionString;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With