Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For a sanity check, try creating a new Web Application Project, open the code behind for the Default.aspx page. Add a line in Page_Load to access your connection string.</p> <p>It should have System.Configuration added as reference by default. You should also see the using statement at the top of your code file already.</p> <p>My code behind file now looks like this and compiles with no problems.</p> <pre><code>using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["MyConnectionStringName"].ConnectionString; } } } </code></pre> <p>This assumes I have a connection string in my web.config with a name equal to "MyConnectionStringName" like so...</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;/configSections&gt; &lt;connectionStrings&gt; &lt;add name="MyConnectionStringName" connectionString="Data Source=.;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre> <p>Yeah, it's elementary I know. But if you don't have any better ideas sometimes it helps to check against something really simple that you know should work.</p>
 

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