delphi 7 对access查询问题
发布网友
发布时间:2024-10-02 06:28
我来回答
共1个回答
热心网友
时间:2024-10-12 04:04
将原:
where post=''IN'' AND POST=TRUE AND FORM_DIS='''+TRIM(E2.TEXT)+''' ORDER BY REF_NO
改成:
where post='+''''+'IN'+''''+' AND POST=TRUE AND '+' FORM_DIS='+''''+TRIM(E2.TEXT)+''''+'ORDER BY REF_NO'
试试。即:所有’均为单引号
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from icmovh where '+'post='+''''+'IN'+''''+' AND POST=TRUE AND '+ 'FORM_DIS='+''''+TRIM(E2.TEXT)+''''+' ORDER BY REF_NO');
ADOQuery1.Open
Delphi中字符串用单引号’,一个单引号用''''表示。
以下是本人的材料进出库管理中的sql的一个写法,请参照(单机版,数据库就用Access,ADO引擎):
strSql:='Select ck1.dh as 单号, sldw as 收料单位,ckrq as 出库日期,'
+'ckdw as 出库单位,spr as 审批人,ysr as 验收人,ckr as 出库人,'
+'xh as 序号,clmc as 名称,clgg as 规格,cldw as 单位,'
+'cldj as 单价,clsl as 数量,clje as 金额'
+' From clck1 as ck1,clck2 as ck2 WHERE (ck1.dh=ck2.dh)'
+' and (ck1.ckrq>=:Date1_0) and (ck1.ckrq<:Date2_0)';
if CheckBox3.Checked Then //选择领料单位
strSql:=strSql+' and ck1.gdbm=:gdbm_0';
if CheckBox4.Checked Then //选择发料(出库)单位
strSql:=strSql+' and ck1.ckbm=:ckbm_0';
strSql:=strSql+' Order By ckrq,ck1.dh'; //按出库日期、单号排序
热心网友
时间:2024-10-12 04:04
将原:
where post=''IN'' AND POST=TRUE AND FORM_DIS='''+TRIM(E2.TEXT)+''' ORDER BY REF_NO
改成:
where post='+''''+'IN'+''''+' AND POST=TRUE AND '+' FORM_DIS='+''''+TRIM(E2.TEXT)+''''+'ORDER BY REF_NO'
试试。即:所有’均为单引号
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from icmovh where '+'post='+''''+'IN'+''''+' AND POST=TRUE AND '+ 'FORM_DIS='+''''+TRIM(E2.TEXT)+''''+' ORDER BY REF_NO');
ADOQuery1.Open
Delphi中字符串用单引号’,一个单引号用''''表示。
以下是本人的材料进出库管理中的sql的一个写法,请参照(单机版,数据库就用Access,ADO引擎):
strSql:='Select ck1.dh as 单号, sldw as 收料单位,ckrq as 出库日期,'
+'ckdw as 出库单位,spr as 审批人,ysr as 验收人,ckr as 出库人,'
+'xh as 序号,clmc as 名称,clgg as 规格,cldw as 单位,'
+'cldj as 单价,clsl as 数量,clje as 金额'
+' From clck1 as ck1,clck2 as ck2 WHERE (ck1.dh=ck2.dh)'
+' and (ck1.ckrq>=:Date1_0) and (ck1.ckrq<:Date2_0)';
if CheckBox3.Checked Then //选择领料单位
strSql:=strSql+' and ck1.gdbm=:gdbm_0';
if CheckBox4.Checked Then //选择发料(出库)单位
strSql:=strSql+' and ck1.ckbm=:ckbm_0';
strSql:=strSql+' Order By ckrq,ck1.dh'; //按出库日期、单号排序