title: C# troubles connecting to a local database
body: <p>I have problems with connecting to my local database. Type of database is <code>.sdf</code> (SQL Server Compact Edition). And I don't understand what is wrong. When I look in my server explorer in data connections at first is ok after running the project it shows on my database bottom red cross.</p>
  
  <p>When I run project I get error: </p>
  
  <blockquote>
    <p>SqlException was unhandled - 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.)</p>
  </blockquote>
  
  <p>My <code>app.config</code> file contains:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="Project3.Properties.Settings.Database1ConnectionString"
           connectionString="Data Source=:C\Users\visualstudio\Project3\Database1.sdf"
           providerName="Microsoft.SqlServerCe.Client.3.5" /&gt;
   &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>And I have also in Program.cs:</p>
  
  <pre><code> string connectionString = Properties.Settings.Default.Database1ConnectionString;
  
   using (SqlCeConnection conect = new SqlCeConnection(connectionString))
   {
        conect.Open();
   }
  </code></pre>