title: Unable to access database (SQL Server CE / Windows Mobile 6.5)
body: <p>I'm creating an application for a Windows Mobile 6.5 device, part of which is supposed to replicate a SQL database when the device plugged in, to have a local copy when unplugged (because no connection).</p>
  
  <p>So, to have a local database I followed the <a href="https://msdn.microsoft.com/library/bb219485.aspx" rel="nofollow noreferrer">"Northwind" tutorial</a> for SQL Server CE (with my own test database), but constantly run into the issue that the device can't connect to the database. I can't debug (because I have to transfer the program to the device to test it every time) but I get this error message (whatever the connection string I try to use):</p>
  
  <blockquote>
    <p>SQL database error: Unspecified error [.\userdb.sdf]</p>
  </blockquote>
  
  <p>I tried multiple connection strings, and I can see the database can be accessed if I bind the data sources to the forms using the designer. But I need to manually set up some query as they will be a lot more complicated than just filling forms.</p>
  
  <p>Here's my code, it's just supposed to fill a form but the next step would be a login/password check:</p>
  
  <pre><code>public partial class UserLogin : Form
  {
      private SqlCeConnection _conn;
  
      public UserLogin()
      {
          InitializeComponent();
  
          _conn = new SqlCeConnection(@"Data Source=.\userdb.sdf;Password=PASSWORD;Persist Security Info=True");  
      }
  
      private void buttonCancel1_Click(object sender, EventArgs e)
      {
          this.Close();
      }
  
      private void buttonLoad1_Click(object sender, EventArgs e)
      {
          try
          {
              SqlCeCommand cmd = new SqlCeCommand();
              cmd.Connection = _conn;
              cmd.CommandText = "SELECT userid, username, password FROM Users";
  
              _conn.Open();
              SqlCeResultSet resultSet = cmd.ExecuteResultSet(ResultSetOptions.Scrollable | ResultSetOptions.Updatable);
              this.bindingSource1.DataSource = resultSet;
  
          }
          catch (SqlCeException sql_ex)
          {
              MessageBox.Show("SQL database error: " + sql_ex.Message);
          }
      }
  </code></pre>
  
  <p>Also something different I tried, where the forms are filled with a DataSet from designer but I still can't manually access the database:
  <a href="https://pastebin.com/10P3wGeP" rel="nofollow noreferrer">https://pastebin.com/10P3wGeP</a></p>