title: Reading data for oracle reader to fill datagridview
body: <p>I have form that has <code>textbox</code> for product ID when user enter an product id 
  I am getting details of product (like PRODUCT_DESC,UNIT_PRICE,...etc) from oracle database and then fill it in <code>datagridview</code> to create list of purchased product</p>
  
  <p>I tried to load dataset but thats will remove the old record when adding new product ID</p>
  
  <p>I tried to loop on <code>dataset</code> and extract values I want and then add them to their column in <code>datagridview</code> the loop here is useless since there is only one record but that wont load data on the <code>datagridview</code> </p>
  
  <p>please how to do it ?? </p>
  
  <p>and is there any better way to do that ?</p>
  
  <pre><code>    private void SelectedProductData()
      {
          string connstr = @"Data Source=orcl; User Id=user; password=pwd;";
          string cmdtxt = @"SELECT PRODUCT_ID,
                                   PRODUCT_DESC,
                                   UNIT_PRICE,
                                   QUANTITY,
                                   MEASUREMENT_UNIT,
                                   MANUFACTORY
                            FROM WAREHOUSE
                              WHERE PRODUCT_ID = :P_Product_ID";
  
          using (OracleConnection conn = new OracleConnection(connstr))
          using (OracleCommand cmd = new OracleCommand(cmdtxt, conn))
          {
              cmd.CommandType = CommandType.Text;
              cmd.CommandText = cmdtxt;
  
              cmd.Parameters.Add(new OracleParameter(":P_Product_ID", OracleDbType.Int32)).Value = TB_Product_ID.Text;
  
              conn.Open();
              OracleDataReader oraReader = cmd.ExecuteReader();
  
              DataTable dt = new DataTable();
              dt.Load(oraReader);
  
              while (oraReader.Read())
              {
                  DGV_INVOICE.CurrentCell.Value = oraReader.GetString(0);
              }
              //foreach (DataRow dr in dt.Rows)
              //{
              //    DGV_INVOICE.Rows[0].Cells[0].Value = dt.Rows[0]["PRODUCT_ID"].ToString();
              //}
          }
      }
  </code></pre>
  
  <p><strong>Code Update</strong></p>
  
  <pre><code>private void TB_Product_ID_Leave(object sender, EventArgs e)
  {
      SelectedProductData();
  }
  </code></pre>
  
  <p>method </p>
  
  <pre><code>private void SelectedProductData()
  {
      string connstr = @"Data Source=JDT; User Id=admin; password=admin;";
      string cmdtxt = @"SELECT PRODUCT_ID,
                               PRODUCT_DESC,
                               UNIT_PRICE,
                               QUANTITY,
                               MEASUREMENT_UNIT,
                               MANUFACTORY
                        FROM WAREHOUSE
                          WHERE PRODUCT_ID = :P_Product_ID";
  
      using (OracleConnection conn = new OracleConnection(connstr))
      using (OracleCommand cmd = new OracleCommand(cmdtxt, conn))
      {
          conn.Open();
  
          cmd.CommandType = CommandType.Text;
          cmd.CommandText = cmdtxt;
  
          cmd.Parameters.Add(new OracleParameter(":P_Product_ID", OracleDbType.Int32)).Value = TB_Product_ID.Text;
  
          OracleDataReader oraReader = cmd.ExecuteReader();
  
          DataTable dt = new DataTable();
  
          dt.Load(oraReader);
  
          while (oraReader.Read())
          {
              DataGridViewRow dgvRow = new DataGridViewRow();
              dgvRow.Cells[0].Value = oraReader.GetValue(2);
              //dgvRow.Cells[0].Value = oraReader.GetString(2);
              //dgvRow.Cells[0].Value = oraReader.GetString(3);
              //dgvRow.Cells[0].Value = oraReader.GetString(4);
  
              DGV_INVOICE.Rows.Add(dgvRow);
          }
          MessageBox.Show("done");
      }
  }
  </code></pre>