title: Why does my local SQL Express have to allow remote connections to use a local MDF?
body: <p>When I set up my VB.net program to read from a local MDF database file (SQL), it tells me that I need remote connections.  Details follow:</p>
  
  <p>I have a Visual Studio <code>vb.net</code> application.   It needs a database, so I downloaded SQL Express and ran a script to add my database.   This worked fine.    Then I wanted to send my program to a colleague, and I thought I should copy the database MDF and LDF files to the App_Data folder of the program, and then use a connection string that can read the MDF.</p>
  
  <p>The connection string seems to be OK:</p>
  
  <pre><code>Server=.\SQLExpress;AttachDbFilename=C:\gideonwroteprograms\EchoTheory\Echo
  Theory\bin\Debug\App_Data\EchoDatabase.mdf;Database=EchoDatabase;Trusted_Co
  nnection=Yes;
  </code></pre>
  
  <p>but I get a message saying I now need to allow remote connections (which I regard as a security risk).<br>
  The message is:</p>
  
  <pre><code>System.Data.SqlClient.SqlException
    HResult=0x80131904
    Message=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: SQL Network 
  Interfaces, error: 26 - Error Locating Server/Instance Specified)
    Source=.Net SqlClient Data Provider
  </code></pre>