Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Specifying the Linq to SQL dbml connection at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TJ - 26 Mar 2008 06:41 GMT
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?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.