Specifying the Linq to SQL dbml connection at runtime

T

TJ

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.
 
M

Marc Gravell

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
 
T

TJ

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top