我正在使用以下插入查询将类型TimeSpan
(duration
变量)的持续时间插入到我的表中具有time[7]
值的字段中。 INSERT是成功的,但它只插入秒,即使持续时间为纳米值,它们始终为0000000.如何插入确切的持续时间?
OleDbConnection conn = new OleDbConnection(cs);
string sql = "UPDATE CampaignRun SET Duration=?,FtpResult=?,FtpCommand=?,Report=? WHERE CampaignId=?";
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
cmd.Parameters.Add("Duration", OleDbType.DBTime).Value = duration;
cmd.Parameters.Add("FtpResult", OleDbType.Boolean).Value = ftpStatus;
cmd.Parameters.Add("FtpCommand", OleDbType.VarChar).Value = ftpCommand;
cmd.Parameters.Add("Report", OleDbType.VarChar).Value = ReadListbox();
cmd.Parameters.Add("CampaignId", OleDbType.BigInt).Value = campaignId;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}