Sunday, May 1, 2011

I found the following solution from . It saved me many hours of trial and error ahead of time. Using the following config change, you can easily change the connectionString used by datasets in the XSD file to another connectionString in one place.

connectionString="Data Source=YOURSQLSERVER;Initial Catalog=YOURDATABASE;
Integrated Security=True"
providerName="System.Data.SqlClient" />

  1. Create your App.Config file

  2. The above XML is all you need in there

  3. Swap out the "PROJECT_NAMESPACE" with your project or assemblies default namespace and "YOURCONNECTIONSTRING" with the Settings.settings file entry, be sure that settings entry is of type "(Connection String)"

  4. Copy the <add /> node from app.config / connectionStrings for this setting into your Web.Config, and that's it, now you can simply configure the connection using the web.config, and retain the original designer connection without ever having to alter the XSD.

No comments: