title: SqlCeDataReader is always null
body: <p>Hey Guys I'm working on Windows Mobile 5.0 (.Net 2.0) 
  and I'm stuck at a small problem where my reader is always being null. My connection is fine and I believe everything else is fine the only problem is with the reader.
  In my exception catch it says </p>
  
  <pre><code>((System.Data.SqlServerCe.SqlCeException)(e)) :  {"The operation completed successfully."}
  InnerException: Could not evaluate expression
  </code></pre>
  
  <p>My database file is not corrupt I opened it outside the application and everything looks fine.
  My code is as follows:</p>
  
  <pre><code>  public static List&lt;Image&gt; GetAll(BOI caller)
      {
          List&lt;Image&gt; images = new List&lt;Image&gt;();
          SqlCeConnection c = Connection.GetConnection(caller.ConnectionString);
  
          if (c != null)
          {
              SqlCeCommand command = new SqlCeCommand("SELECT * FROM Images", c);
  
              SqlCeDataReader reader = null;
              try
              {
                  reader = command.ExecuteReader();  &lt;&lt;&lt;&lt;&lt; reader is null &lt;&lt;&lt;&lt;&lt;&lt;&lt;
              }
              catch (Exception e)
              {
                  while (reader != null &amp;&amp; reader.Read())
                  {
                      Image temp = new Image((int)reader["imageKey"],
                                (String)reader["filename"],
                                (byte[])reader["image"],
                                (reader["labelKey"] == DBNull.Value ? null : (int?)reader["labelKey"]),
                                (int)reader["priority"]);
                      temp.SetDBName(caller.ConnectionString);
  
                      images.Add(temp);
                  }
              }
          }
  
          return images;
      }
  </code></pre>
  
  <p><strong>EDIT</strong>
  I open my connection in Connection.GetConnection(..);</p>
  
  <p><strong>EDIT:2</strong>
  The e.StackTrace:</p>
  
  <pre><code>   at System.Data.SqlServerCe.SqlCeDataReader.ProcessResults(Int32 hr)
     at System.Data.SqlServerCe.SqlCeDataReader.FillMetaData(SqlCeCommand command)
     at System.Data.SqlServerCe.SqlCeCommand.InitializeDataReader(SqlCeDataReader reader, Int32 resultType)
     at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
     at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader(CommandBehavior behavior)
     at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader()
     at Oralys.BOI.DataAccess.ImageMapper.GetAll(BOI caller)
     at Oralys.BOI.BOI.get_Images()
     at Oralys.BOI.BOI_Controller.FetchAllImages()
     at IdeoVoiceMobile.RunProfile.InitBOI()
     at IdeoVoiceMobile.RunProfile..ctor()
     at IdeoVoiceMobile.Program.startProfile()
     at IdeoVoiceMobile.Program.Main()
  </code></pre>
  
  <p>Get Connection function: </p>
  
  <pre><code>    public static SqlCeConnection GetConnection(string connectionString)
      {
          SqlCeConnection conn = null;
          try
          {
              if (connections.Count == 0)
              {
                  OpenConnection(connectionString);
              }
              conn = connections[connectionString];
          }
          catch (System.Exception)
          {
          }
          return conn;
      }
  </code></pre>
  
  <p><strong>EDIT:3</strong>
  Exception code when using  </p>
  
  <blockquote>
    <p>SqlCeCommand command = new SqlCeCommand("SELECT * FROM Images Where
    imageKey=6", c);</p>
  </blockquote>
  
  <pre><code>ExceptionCode: 0xc0000005
  ExceptionAddress: 0x0115438c
  Reading: 0x00000000
  Faulting module: sqlceqp35.dll
  Offset: 0x0001438c
  
     at NativeMethods.GetKeyInfo(IntPtr pIUnknown, IntPtr pTx, String pwszBaseTable, IntPtr prgDbKeyInfo, Int32 cDbKeyInfo, IntPtr pError)
     at SqlCeDataReader.FillMetaData(SqlCeCommand command)
     at SqlCeCommand.InitializeDataReader(SqlCeDataReader reader, Int32 resultType)
     at SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
     at SqlCeCommand.ExecuteReader(CommandBehavior behavior)
     at SqlCeCommand.ExecuteReader()
     at ImageMapper.GetAll(BOI caller)
     at BOI.get_Images()
     at BOI_Controller.FetchAllImages()
     at RunProfile.InitBOI()
     at RunProfile..ctor()
     at Program.startProfile()
     at Program.Main()
  </code></pre>