title: c# Access OleDB err 80004005
body: <p>I'm working on an app with an Access 2010 db connection and I keep receiving OleDB error 80004005 and I can't figure out why.<br></p>
  
  <pre><code>            const String conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\OneDrive\Dropbox\SharpDevelop Projects\electronics inventory\electronics.mdb";
      const String qCont = "select Section, Number, Stock from Container where Component = @IdComp order by Section, Number";
  
      int oldParamSubcat = 0;
      OleDbConnection connection = new OleDbConnection(conn);
  
      void GrdCompCellClick(object sender, DataGridViewCellEventArgs e)
      {
          String IdComp = grdComp[grdComp.Columns["ID"].Index, grdComp.CurrentCell.RowIndex].Value.ToString();
          try
          {
              grdSubcat.DataSource = null;
              grdSubcat.Rows.Clear();
              grdSubcat.Columns.Clear();
              connection.Open();
              OleDbCommand cmdDetail = new OleDbCommand();
              cmdDetail.Connection = connection;
              cmdDetail.CommandText = qDetail;
              cmdDetail.Parameters.AddWithValue("@IdComp", Convert.ToInt32(IdComp));
  
              txtDetails.Text = "";
              OleDbDataReader rdDetail = cmdDetail.ExecuteReader();
  
              rdDetail.Read();
              txtDetails.Text = rdDetail["Component"].ToString() + "\r\n";
              txtDetails.Text += rdDetail["Parameter"].ToString() + ": ";
              txtDetails.Text += rdDetail["Val"].ToString() + "\r\n";
  
              while(rdDetail.Read())
              {
                  txtDetails.Text += rdDetail["Parameter"].ToString() + ": ";
                  txtDetails.Text += rdDetail["Val"].ToString() + "\r\n";
              }
  
              rdDetail.Close();
              connection.Close();
              connection.Open();
  
              OleDbCommand cmdCode = new OleDbCommand();
              cmdCode.Connection = connection;
              cmdCode.CommandText = qCode;
              cmdCode.Parameters.AddWithValue("@IdComp", Convert.ToInt32(IdComp));
  
              txtDetails.Text += "\r\n";
              OleDbDataReader rdCode = cmdCode.ExecuteReader();
  
              while(rdCode.Read())
              {
                  txtDetails.Text += rdCode["Seller"].ToString() + ": ";
                  txtDetails.Text += rdCode["Code"].ToString() + "\r\n";
              }
  
              rdCode.Close();
              connection.Close();
              connection.Open();
  
              OleDbCommand cmdCont = new OleDbCommand();
              cmdCont.Connection = connection;
              cmdCont.CommandText = qCont;
              cmdCont.Parameters.AddWithValue("@IdComp", Convert.ToInt32(IdComp));
  
              txtDetails.Text += "\r\n";
              OleDbDataReader rdCont = cmdCont.ExecuteReader(); ////////// here is where i receive the error ///////////////
  
              while(rdCont.Read())
              {
                  txtDetails.Text += "Container: ";
                  txtDetails.Text += rdCont["Section"].ToString() + "-";
                  txtDetails.Text += rdCont["Number"].ToString() + " = ";
                  txtDetails.Text += rdCont["Stock"].ToString() + " units\r\n";
              }
  
              rdCont.Close();
              connection.Close();
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.ToString());
          }
      } 
  </code></pre>
  
  <p>The rest of the code works perfectly, I only get the error on cmdCont.ExecuteReader();<br>
  <a href="https://i.stack.imgur.com/1Hv3d.png" rel="nofollow noreferrer">The error message</a><br>
  If i execute the query in Access, it runs ok.<br>
  Any ideas are very much welcome.<br>
  Thanks.<br></p>