Avatar of AlHal2
AlHal2
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Set sqldatasource at run time

The below asp code sets an sqldatasource.  
I want the the program to look at C:\InetPub\wwwroot\web.config and set the connection string based upon what it finds there.  In other words the parameter ConnectionStrings:DS2DSSQLConnStr won't be set until the program has checked C:\InetPub\wwwroot\web.config

What's the best way to do this?

<asp:SqlDataSource ID="sdsSchemas" runat="server" ConnectionString="<%$ ConnectionStrings:DS2DSSQLConnStr %>"
        SelectCommand="RO_SelectEquityCSchema" SelectCommandType="StoredProcedure" 
        UpdateCommand="RO_UpdateCSchema" UpdateCommandType="StoredProcedure">
        <SelectParameters>
            <asp:SessionParameter Name="rtrExchangeCode" SessionField="RTRExch" />
            <asp:SessionParameter Name="rtrInstrumentTypeCode" SessionField="RTRitc" />            
        </SelectParameters>        
        <UpdateParameters>
            <asp:Parameter Name="FileNameCode" Type="String" />
            <asp:Parameter Name="Required" Type="String" />
            <asp:Parameter Name="rc" Type="int16" Direction="output" />
        </UpdateParameters>
    </asp:SqlDataSource>

Open in new window

ASP.NET.NET Programming

Avatar of undefined
Last Comment
AlHal2

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
David Johnson, CD

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AlHal2

ASKER
Thanks.  I simply moved the connection string from web.config for this program to C:\inetpub\wwwroot\web.config.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes