单独执行SQL语句成功,用C#执行SQL语句提示DBNull,很无奈~~
SQL = String.Format("select a.snum1 + b.snum2 + c.snum3 + d.snum4 + e.snum5 from (select sum(cast(首次收款金额 as decimal(18,2))) snum1 from salescontentservice where 首次收款日期 >= '{0}' and 首次收款日期 <= '{1}')a , (select sum(cast(二次收款金额 as decimal(18,2))) snum2 from salescontentservice where 二次收款日期 >= '{2}' and 二次收款日期 <= '{3}')b , (select sum(cast(三次收款金额 as decimal(18,2))) snum3 from salescontentservice where 三次收款日期 >= '{4}' and 三次收款日期 <= '{5}')c ,(select sum(cast(四次收款金额 as decimal(18,2))) snum4 from salescontentservice where 四次收款日期 >= '{6}' and 四次收款日期 <= '{7}')d ,(select sum(cast(五次收款金额 as decimal(18,2))) snum5 from salescontentservice where 五次收款日期 >= '{8}' and 五次收款日期 <= '{9}')e", startdate, enddate, startdate, enddate, startdate, enddate, startdate, enddate, startdate, enddate);
object theit = dbt.ExecuteObject(SQL);
if (theit != System.DBNull.Value)
{
this.label1.Text = theit.ToString();
}
else
this.label1.Text = "";