In my web application I have an admin page where I am able to customize my connection strings at runtime, let's say the connection strings look like the following:

<add name="newString1" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString2" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString3" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString4" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString5" connectionString="Data Source=;Initial Catalog=;User ID=; Password="

The connection strings are blank at first until the user changes them from the admin page, once changed they are written to the web.config file and will always be there even if the application is restarted.

I then have an SQL datasource like the following:

 <asp:SqlDataSource 
            ID="SqlDataSource1" 
            runat="server" 
            ConnectionString="<%$ ConnectionStrings:newString1 %>"
            SelectCommand="SELECT * FROM [Table] WHERE ([Code] = @Code )">
            <SelectParameters>
                <asp:ControlParameter ControlID="dropdownlist" Name="Code" PropertyName="Text" Type="String" />
            </SelectParameters>  
</asp:SqlDataSource>

Because I am able to overwrite any of the connection strings, let's say I have 3 sets of data and each set of data is on a different server, and for example let's say the SQL datasource handled logins. (the one provided doesn't, that is just an example)

how would I go about checking which connection string me or someone else has saved the logins connection string to? has the user saved the connection string to the logins database in newstring1? newstring2? .. and so on.

From testing I've realised I am unable to use multiple connection strings in one data source.

Related posts

Recent Viewed