For an ASP.NET C# application is it possible to set the Connection
property of a Linq to SQL dbml class at runtime, such as in the
global.asax class.
I know I can always specify a connection string when forming a query,
i.e DALDataContext dc = new DALDataContext(connectionstring); but when
I am using LinqDataSource in markup, this is not possible.
Marc Gravell - 26 Mar 2008 07:50 GMT
You would typically do this through configuration (web.config in this
case) - in particular in the "connectionStrings" section.
You can specify the key in the dbml, either in the designer
(Connection : Application Settings) or the xml itself (Connection :
@Mode, @SettingsObjectName and @SettingsPropertyName)
Marc
TJ - 28 Mar 2008 05:30 GMT
yes, I am storing the default database in the configuration in the
web.config. But I need the system to determine the correct database at
runtime.
Can I change the connection in the xml at runtime?