Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Specifying the Linq to SQL dbml connection at runtime

20 views
Skip to first unread message

TJ

unread,
Mar 26, 2008, 1:41:25 AM3/26/08
to
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

unread,
Mar 26, 2008, 2:50:32 AM3/26/08
to
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

unread,
Mar 28, 2008, 12:30:49 AM3/28/08
to
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?

0 new messages