title: VB.NET. How to get data from sdf database?
body: <p>We are developing windows form app. We have local database which is sdf file. We added reference to our project: SQLServerCe.dll</p>
  
  <p>We are using this code:</p>
  
  <pre><code>Dim strDataSource As String
  strDataSource = "Data Source = C:\Users\JOE\Desktop\Class work (7)\Class work\BookIt\BookIt.DBEntity\Library.sdf"
  Dim conn As New SqlCeConnection
  conn.ConnectionString = strDataSource &amp; ";Password='&lt;password&gt;'"
  
  Dim selectCmd As SqlCeCommand = conn.CreateCommand
  selectCmd.CommandText = "SELECT author, title FROM book"
  
  Dim adp As New SqlCeDataAdapter(selectCmd)
  
  Dim ds As New DataSet
  
  ' Note: Fill will leave the connection in its original state;
  ' In this case, the connection was closed so it will be left closed
  adp.Fill(ds)
  
  tbAuthor.Text = ds.Tables(0).Rows(0)(0).ToString()
  tbTitle.Text = ds.Tables(0).Rows(0)(1).ToString()
  </code></pre>
  
  <p>This code is not working. This line is giving error:</p>
  
  <pre><code>adp.Fill(ds)
  </code></pre>
  
  <p>Error: An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll</p>
  
  <p>What we are doing wrong? How to solve this problem?</p>