遇到点麻烦,大家帮看一下
string strDate1="";
string strSql=string.Format("select * from (select * ,convert(varchar(20),(select top 1 StartDate from Fee where Fee.UserId=BaseInfo.id order by id desc),111) as StartDate ,convert(varchar(20),(select top 1 endDate from Fee where Fee.UserId=BaseInfo.id order by id desc),111) as endDate,(select top 1 InvoiceNum from Fee where Fee.UserId=BaseInfo.id order by id desc) as InvoiceNum from BaseInfo) as c where c.UserType={0} and c.{1}",intType,strDate1);

strDate1=string.Format("BDate>='{0}' and c.BDate<='{1}'",startDate,endDate);DataSet ds=SqlHelper.ExecuteDataset(strSql);
设断点的时候,strDate1为“BDate>='2000' and c.BDate<='2050'”
但是ds里的strSql却总是“c.”后面都是空的,不知道问题在哪里,哪位高手指教?

解决方案 »

  1.   

    你把strDate1=string.Format("BDate>='{0}' and c.BDate<='{1}'",startDate,endDate);
    放到string strDate1="";的后面试试。
      

  2.   

    strDate1是空的,真奇怪,还是不行,为什么strDate1=string.Format("BDate>='{0}' and c.BDate<='{1}'",startDate,endDate);中,startDate,endDate是有值的,但strDate1却是空的,值传不了,哪位帮再分析一下,谢谢
      

  3.   

    在你执行string strSql=strin......时这一句strDate1=string.Format("BDate.....还没有执行,所以strDate1="".修改如下
    string strDate1="";
    strDate1=string.Format("BDate>='{0}' and c.BDate<='{1}'",startDate,endDate);string strSql=string.Format("select * from (select * ,convert(varchar(20),(select top 1 StartDate from Fee where Fee.UserId=BaseInfo.id order by id desc),111) as StartDate ,convert(varchar(20),(select top 1 endDate from Fee where Fee.UserId=BaseInfo.id order by id desc),111) as endDate,(select top 1 InvoiceNum from Fee where Fee.UserId=BaseInfo.id order by id desc) as InvoiceNum from BaseInfo) as c where c.UserType={0} and c.{1}",intType,strDate1);
    DataSet ds=SqlHelper.ExecuteDataset(strSql);