title: Connection Error in SQL Server Compact with ASP.Net
body: <p>I am trying to access a database, using a <code>DataSet</code>. I am using Visual Studio for Web Express 2013, ASP Web Forms project with SQL Server Compact 4.0. I created the database from Database Explorer, added 3 tables, now my code has <code>getData</code>, <code>setData</code> methods which will use <code>Dataset</code> to get data. </p>
  
  <p>But the <code>SqlConnection</code> object is throwing exception at runtime.</p>
  
  <blockquote>
    <p>[SqlException (0x80131904): 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:<br>
     26 - Error Locating Server/Instance Specified)]</p>
  </blockquote>
  
  <p>I guess this is due to connection string since error is at line:</p>
  
  <pre><code>SLQCon.Open();
  </code></pre>
  
  <p>I have tried more than one method but none of them has worked yet. These are few of them,</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/jj653752%28v=vs.110%29.aspx#sqlce" rel="nofollow">msdn link </a></p>
  
  <p><a href="https://www.connectionstrings.com/sql-server-2008/" rel="nofollow">Connection Strings</a></p>
  
  <p>The other things work fine (web form controls), only problem is when I do something related to database, any fixes?</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>void setData(string tableName) {   
      string ConString = @"Data Source=" + "F:\\Github\\JournalClassifier\\WebApplication1\\WebApplication1\\App_Data\\KeywordsDB.sdf" + ";Connect Timeout=30";
  
      SQLCon.ConnectionString = ConString; 
  
      SQLCon.Open();      // Exception here
  
      // insertion code  
  }
  </code></pre>