title: Programmatically getting data from a MySQL dataset
body: <p>I have been searching for days all over the web, including this place for the answer to my question - all to no avail. At first I hesitated to ask here because last time I asked a question I got severely beaten for not asking it properly. So I'll try again. Here's the scenario:</p>
  <p>I have built a Windows desktop application for our company to track customer orders. It uses a MySQL database hosted on my own server. It is fairly simple and it's working fine. My application has several different data bound controls and all is well. Really, it works just great.</p>
  <p>There is a datagridview which displays all the orders a particular customer has placed. When the user clicks on the Order Number column in one of the rows a query is run which returns data specific to that order. One piece of data returned is the status of that order.</p>
  <p>But I want to access that one piece of data WITHOUT using a data bound control - in this case it's a text box bound to one of the fields in a table in my database. I hide that control because it shows some rather cryptic data.  That piece of data is a status code for the orders in the table. These codes are not self-apparent - they mean nothing unless you know what they refer to. You can see this in the code snippet below. I would rather not have this hidden text box on the form. I would rather obtain the value programmatically but I cannot for the life of me find the proper way to do this.</p>
  <p>My code snippet:</p>
  <pre><code>private void getCustData2DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
          {
              string ordnum = null;
              string statusCode = null;
              
                  if (e.RowIndex &gt;= 0)
                  {
                      DataGridViewRow row = getCustData2DataGridView.Rows[e.RowIndex];
                      ordnum = row.Cells[0].Value.ToString();   
                  }
  
                  try
                  {
                      this.ecom_ordersTableAdapter.Fill(this.rBTCO_DBDataSet1.ecom_orders, ordnum);
                  }
                  catch (System.Exception ex)
                  {
                      System.Windows.Forms.MessageBox.Show(ex.Message);
                  }
  
              
              statusCode = statusdata.Text; //gets the value from the hidden textbox which is bound to the &quot;status&quot; field in the ecom_orders table.
  
              switch (statusCode)
              {
                  case &quot;NS&quot;:
                      label5.Text = &quot;Processing&quot;;
                      label5.ForeColor = Color.Green;
                      break;
                  case &quot;P&quot;:
                      label5.Text = &quot;Pending Payment&quot;;
                      label5.ForeColor = Color.Blue;
                      break;
                  case &quot;X&quot;:
                      label5.Text = &quot;Cancelled&quot;;
                      label5.ForeColor = Color.Red;
                      break;
                  case &quot;C&quot;:
                      label5.Text = &quot;Completed&quot;;
                      label5.ForeColor = Color.Blue;
                      break;
                  default:
                      label5.Text = null
                      label5.ForeColor = Color.Black;
                      break;
  
              }
          }
  </code></pre>
  <p>The status codes reside in the rbtcoDataSet1.ecom_orders table.
  You can see in the <code>switch</code> block where I assign strings to the different status codes so they have meaning to the user. Since all the database manipulation in this application has been generated by Visual Studio I really don't have a clue as how to get this one piece of data without using a bound control. Can it even be done in this case?</p>
  <p>Let the beatings commence. Please be gentle!</p>