DanDan DanDan - 1 year ago 116
C# Question

Changing dataset connection string at runtime

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.

Answer Source

You can modify a single instance of the table adapter.

_myAdapter.Connection.ConnectionString = connectionString;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download