title: Unable to cast object of type 'System.DBNull' to type 'System.String'. Error
body: <p>I keep getting this error because the VendorID is null for that record. I've seen that this question has been asked a couple times and it seems like I should just do a check to see if null before it converts it and enters it in the dbtable, but I'm not sure how to do that.</p>
  
  <pre><code>public static PartOrder findPartOrder(string orderNo)
      {
          PartOrder aPartOrder = new PartOrder();
          OleDbDataAdapter myAdapter = new OleDbDataAdapter();
          if (aConnection.State == ConnectionState.Closed)
              aConnection.Open();
          OleDbCommand cmd = aConnection.CreateCommand();
          OleDbDataReader dbReader = null;
          cmd.CommandText = "SELECT * FROM PartOrder WHERE OrderNo = '" + orderNo + "'";
          dbReader = cmd.ExecuteReader();
  
          while (dbReader.Read())
          {
              aPartOrder.OrderNo = (string)dbReader.GetValue(0);
              aPartOrder.Length = (string)dbReader.GetValue(1);
              aPartOrder.Finish = (string)dbReader.GetValue(2);
              aPartOrder.Cost = (string)dbReader.GetValue(3);
              aPartOrder.PartDrawingNo = (string)dbReader.GetValue(4);
              aPartOrder.VendorId = (string)dbReader.GetValue(5);
              aPartOrder.ShopId = (string)dbReader.GetValue(6);
              aPartOrder.Completed = (string)dbReader.GetValue(7);
          }
  
          dbReader.Close();
          return aPartOrder;
      }
  </code></pre>
  
  <p>Again, the line "aPartOrder.VendorId = (string)dbReader.GetValue(5);" gets the error because VendorId is null.</p>