How to get a value to return in a textbox?
<p>The program is to supposed count the refurb in the db and return a value in a textbox. I initialized my values to 0, but my problem is how do I get it to calculate each time a user scans in a unit to be refurbed. Anything I try to do gives me an error in my program. Right now it's returning a value of of 1 because I added RefurbRate++. Can anyone help me? </p>

<p>Here is what I've done with my code:</p>

<p>Collapse</p>

<pre><code>private int GetRefurbRate()
{
     string sql = "";
     int Refurb_Rate = 0;
     int totalRefurb = 0;
     int totalUnits = 0;
     string error_msg = "";

     sql = "SELECT COUNT(*) " +
            "FROM " + schema + ".repair_part rp  " +
            "WHERE rp.repair_ord = '" + txtRO.Text + "' ";
     while (true)
     {
          if (!myDb.RunSql(sql, true))
          {
             error_msg = "DBError for getting Refurb Rate";
             break;
          }
          if (myDb.dbRdr.HasRows)
          {
              if (myDb.dbRdr.Read())
              {
                 try
                 {
                     Refurb_Rate = (totalRefurb / totalUnits * 100);
                 }
                 catch (Exception e)
                 {
                      Console.WriteLine(e);
                 }
               }

              Refurb_Rate++;
          }
          break;
     }
     myDb.dbRdr.Close();
     if (error_msg != String.Empty)
     {
         MessageBox.Show(error_msg, "Get Refurb Rate",
                          MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     return Refurb_Rate;
}
</code></pre>
