title: Asp.net Unable to Connect to MSSQL
body: <p>When I try to launch the web project in asp.net with MSSQL, it seems like I cannot connect to my database. The error message is: </p>
  
  <pre><code>A network related or instance specific error occurred while establishing a connection to SQL server...
  </code></pre>
  
  <p>But when I try to run my previous projects, it works. However, when I select All Program -> Microsoft SQL Server 2008 -> Configuration Tools -> SQL Server Configuration Manager -> SQL Server Services. Instead of listing all the services, it shows me an error which is The remote procedure call failed.</p>
  
  <p>I wonder how to fix this as it only happens for one of my project. Thanks in advance.</p>
  
  <p><img src="https://i.stack.imgur.com/44yLG.png" alt="Snapshots of SQL Server Configuration Manager"></p>
  
  <p><img src="https://i.stack.imgur.com/5Hn99.png" alt="Snapshots of services"></p>
  
  <p>My web.config codes:</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    --&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt;
        &lt;section name="GeospatialChallenge2014.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
      &lt;/sectionGroup&gt;
    &lt;/configSections&gt;
    &lt;system.web&gt;
      &lt;webServices&gt;
        &lt;protocols&gt;
          &lt;add name="HttpSoap" /&gt;
          &lt;add name="HttpGet" /&gt;
          &lt;add name="HttpPost" /&gt;
        &lt;/protocols&gt;
      &lt;/webServices&gt;
      &lt;compilation debug="true" targetFramework="4.0"&gt;
      &lt;/compilation&gt;
      &lt;pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" /&gt;
    &lt;/system.web&gt;
  
    &lt;connectionStrings&gt;
      &lt;add name="GeospatialChallengeConnectionString" connectionString="Data Source=(local);Initial Catalog=SAFETY_AT_SG_DATABASE.mdf;"
      providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  
    &lt;applicationSettings&gt;
      &lt;GeospatialChallenge2014.Properties.Settings&gt;
        &lt;setting name="GeospatialChallenge2014"
          serializeAs="String"&gt;
          &lt;value&gt;http://localhost/SgDataService.asmx&lt;/value&gt;
        &lt;/setting&gt;
      &lt;/GeospatialChallenge2014.Properties.Settings&gt;
    &lt;/applicationSettings&gt;
    &lt;system.webServer&gt;
      &lt;directoryBrowse enabled="true" /&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And my connection string:</p>
  
  <pre><code> using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.Text;
  using System.Web;
  using System.Web.Services;
  using System.Data;
  using System.Data.SqlClient;
  using System.Configuration;
  
  using System.Xml;
  
  namespace Geospatial_Challenge_2014
  {
      /// &lt;summary&gt;
      /// Summary description for SgDataService
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      // [System.Web.Script.Services.ScriptService]
      public class SgDataService : System.Web.Services.WebService
      {
  
          [WebMethod]
          public DataSet GetTrafficByDateTime(string StartDateTime, string EndDateTime)
          {
              //System.Data.SqlClient.SqlConnection myConn = new System.Data.SqlClient.SqlConnection();
              //myConn.ConnectionString = @"Data Source=(local);Initial Catalog=SAFETY_AT_SG_DATABASE.MDF;Integrated Security=True";
              SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["GeospatialChallengeConnectionString"].ConnectionString);
              SqlDataAdapter myAdapter = new SqlDataAdapter("Select * from dbo.Traffic where Convert(DateTime,([date]+' '+[time])) &gt;= @StartDateTime AND Convert(DateTime,([date]+' '+[time])) &lt;= @EndDateTime;", myConn);
              myAdapter.SelectCommand.Parameters.AddWithValue("@StartDateTime", StartDateTime);
              myAdapter.SelectCommand.Parameters.AddWithValue("@EndDateTime", EndDateTime);
              DataSet ds = new DataSet();
              myConn.Open();
              myAdapter.Fill(ds, "Traffic");
              myConn.Close();
              return ds;
          }
      }
  }
  </code></pre>