title: Cannot connect to sql server 2008 express locally
body: <p>I am trying to connect to a local host sql server 2008 express server. I am running my c# asp.net code locally as well (testing before I connect to dev servers). I cannot get the code to connect to the database. I copied the connection string from the properties of the database created within visual studio 2010, and tried using that, but it did not work. Then I used: </p>
  
  <pre><code>//Build the connection 
      SqlConnectionStringBuilder bldr = new SqlConnectionStringBuilder();
  
      //Put your server or server\instance name here.  Likely YourComputerName\SQLExpress
      bldr.DataSource = "(localhost)/SQLEXPRESS;";
  
      //Attach DB Filename
      bldr.AttachDBFilename = "C:/Documents and Settings/1091912/My Documents/Visual Studio 2010/WebSites/BrokerBuy/App_Data/BrokerBuy.mdf";
  
      //User Instance
      bldr.UserInstance = true;
  
      //Whether or not a password is required.
      bldr.IntegratedSecurity = true;
  
      SqlConnection connectionString = new SqlConnection(bldr.ConnectionString);
      connectionString.Open();
  </code></pre>
  
  <p>But this does not work either. I have also tried ./SQLEXPRESS for my datasource name, but this did not work either. The error that comes up is :</p>
  
  <p><em>"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"</em></p>
  
  <p>I have also checked to ensure sql server express is running (it is) and that all connections but via are enabled. I cannot get the connection to work. Any ideas?</p>