V2.0 ConnectionSettings config section

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
So nice of them to design ConfigurationManager.ConnectionSettings("MyConnection").ConnectionString

Has anybody figured out how to use this when using a ...DataSource object

In otherwords on a SQLDataSource object, the connection string can look at the web.config file (rather having to create a new one).

Or for AccessDataSource object, the DataFile could look at the connection string rather than having to add the database to your App_Data or manually typing in the path.

To me this would be great usability.
 
Given a web.config that contains
Code:
<connectionStrings>
    <add name="Northwind" connectionString="Data Source=(local);Initial Catalog=Northwind;uid=sa;pwd=" providerName="SqlClient"/>
</connectionStrings>

You can declare a DataSource object like
Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:Northwind %>"

Is that what you mean? Note that under asp.net 2.0 a lot of what used to be code for data binding can now be moved into the asp tags and made a lot more declarative.
 
Back
Top