私は現在、特定の期間内の従業員の合計をtotalhours
とdouble
という形式でデータベースから取得していますが、問題はデータベースをチェックして従業員に遅くなるとreader = null
となります。だから、私はisDBNull
を使用することを決定したが、私はif (!myReader.IsDBNull(myReader.GetDouble("total")))
を挿入すると、myReader.Getdouble("total")
はreader.GetDoubleにはintが必要ですか?
システムがこれはint型
cc.SetCMD(@"SELECT SUM(AccHours) AS total FROM mia_payroll.tbl_late WHERE COP_ID = @ID AND EID = @EID;");
using (myConn = new MySqlConnection(ConnectionClass.GetConnection()))
{
myConn.Open();
using (cmDB = new MySqlCommand(cc.GetCMD(), myConn))
{
cmDB.Parameters.AddWithValue("@ID", lblCOID.Text);
cmDB.Parameters.AddWithValue("@EID", EID);
try
{
using (myReader = cmDB.ExecuteReader())
{
while (myReader.Read())
{
if (!myReader.IsDBNull(myReader.GetDouble("total")))
{
total = myReader.GetDouble("total");
}
else
{
total = 0;
}
txtLate.Text = System.Convert.ToString(total);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
myConn.Close();
}