Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag 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

ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlHal2

ASKER

Thanks.  I simply moved the connection string from web.config for this program to C:\inetpub\wwwroot\web.config.