''''+'诊断计划.'+Trim(ComboBox3.Text+''''

解决方案 »

  1.   

    SQL.Add(''+'诊断计划.'+Trim(ComboBox3.Text)+'');这样就可以了,哈哈
      

  2.   

    我晕! 最好先后一个字符串接起SQL语句,然后再把字符串赋给ADOQUERY!
      

  3.   

    ADOQuery1.SQL.TEXT打印出来看一下,注意一下sql里面的空格,from join where 他们都需要用空格与条件隔开的
      

  4.   


      ' where 诊断计划.'+Trim(ComboBox3.Text)+'='+QuotedStr(Trim(Edit3.Text));  这样写法就可以了!
      Where前面加空格,.字段不能有空格 后面的值要加双引号(等效于QuotedStr)  
      

  5.   

    用quotedstr()函数就OK了,自动跟你加''号
      

  6.   

    sql语句这样写不好吧,首先容易本身出错,而且检查麻烦,其次,维护也不大好啊
      

  7.   

    檢查是否有空格存在
    建議SQL數據庫表關聯級聯語句使用別名,(別名或表名)盡量不要使用中文字段。。尤其是寫在sourcecode中
    For example:select *,(select COLDSC from RES_BUYER_CODE where COLCODE=ff.BuyerCode) as ZQ from (
      select a.Account_Id,a.full_name,a.zj,a.CB,a.BM,a.KB,a.xb,a.jcrq,a.SF,a.BYXX,a.ZJQF,ltrim(rtrim(a.xl)) as xl,ltrim(rtrim(a.jn)) as jn,a.cbzx,a.sex,a.address,a.sfzno,a.lzr,b.Startdt,b.enddt,b.paramid as id,b.mbid,getdate() as NewDate,
      (case ltrim(rtrim(a.zjqf)) when 'D1' then (select max(buyercode) from res_xb where xb=a.xb) else (select BuyerCode From JJ_BC where GH=a.Account_ID) end) as BuyerCode,
          (select mb_alias from RES_HTMB where id=b.MBID ) as 'mbname',      
          (case b.approve when (select ID from RES_HT_Status where id=b.approve) then (select StatusName from RES_HT_Status where id=b.approve) else '' end) as Approve,      
          (case when EXISTS(select account_id from syqkh  where account_id=a.account_id) then (select statusname from res_ht_status where Id=(select khstatus from syqkh e where e.account_id=a.account_id) ) else '未打印' end) as khstatus,
          (case when EXISTS(select account_id from syqkh  where account_id=a.account_id) then (select statusname from res_ht_status where Id=(select kh from syqkh f where f.account_id=a.account_id) ) else '未考核' end) as kh,dateadd(mm,3,a.jcrq) as khrq1,
          (case when EXISTS(select account_id from syqkh  where account_id=a.account_id) then (select statusname from res_ht_status where Id=(select DSH from syqkh f where f.account_id=a.account_id) ) else '' end) as DSH,
          d.khrq2,('KH'+ CONVERT(nvarchar(50),a.jcrq,112)+ convert(nvarchar(50),a.account_id)) as khbh,
          (case b.htstat when (select ID from RES_HT_Status where id=b.htstat) then (select StatusName from RES_HT_Status where id=b.htstat) else '未簽' end) as Htstat,      
          (case b.htjbzt when (select ID from RES_HT_Status where id=b.htjbzt) then (select StatusName from RES_HT_Status where id=b.htjbzt) else '待簽' end) as htjbzt,      
          (select TEndDt2 from RES_ht_param where id=b.paramid) as sxr,
          b.cdwz from Res_Hrd_Temp a left join RES_HTQD b
          on a.Account_Id=b.Usrid left join syqkh d on a.account_id=d.account_id  ) ff where isnull(ff.sfzno,'')<>''
          and ff.Account_Id not like '9____' and ff.account_id not like '7____' and ff.Account_Id not like '8____'  
          and (ff.Account_Id not In(select Account_Id from Res_Hrd_Temp where JN='離職' and Account_Id not in (select Usrid from RES_HTQD)))
          order by ff.account_id