Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to validate ConnectionString exists and if not do not throw error
    primarykey
    data
    text
    <h3>The connection name 'MySqlServer' was not found in the applications configuration or the connection string is empty.</h3> <p>So, I have a page with a panel that will display when the connection in the web config is found and the connection is valid; using a try/catch as long as the add name"VALUE" is in the config connection strings if the server data is bad the page will load and the panel is set to invisible... I need to be able to handle the following...</p> <p>If the named value in this case MySqlServer is used in the aspx; aspx.cs but not found in the config I do not want the error to occur; connection name was not found.... I just want to not show the panel like when the SqlConnection.Open fails when the name is found but data is bad...</p> <p>aspx</p> <pre><code> &lt;asp:SqlDataSource runat="server" ID="allowedIPsSqlDataSource" ConnectionString="&lt;%$ ConnectionStrings:MySqlServer %&gt;" </code></pre> <p>aspx.cs</p> <pre><code>string connectionString = ConfigurationManager.ConnectionStrings["MySqlServer"].ToString(); SqlConnection SqlConnection = new SqlConnection(connectionString); SqlCommand SqlCommand = new SqlCommand(); try { SqlConnection.Open(); </code></pre> <p>config</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="NotMySqlServer" providerName="System.Data.SqlClient" connectionString="server=TEST\SQL2005;database=ADB;Integrated Security=True"/&gt; &lt;add name="NotMy2SqlServer" providerName="System.Data.SqlClient" connectionString="server=TEST\SQL2005;database=ADB;Integrated Security=True"/&gt; &lt;/connectionStrings&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload