W
wdsu
Unregistered / Unconfirmed
GUEST, unregistred user!
我的数据表如下:
客户表:
customer: int char char char
customerid customername customeraddr customertel
客户编号 客户姓名 客户地址 客户电话
定单表:
orders: int int date int
ordersno customerid orderdate ordersnum
定单编号 客户编号 定货日期 定单总数量
详细记录表:
ordersdetail int int int int
ordersno itemsno partsno numbers
定单编号 子项目序号 产品代号 数量
procedure Tfm_qrydatecust.btnqryClick(Sender: TObject);
var
wheresql,strcust:string;
begin
if (cbxcust.Items[cbxcust.ItemIndex]='全部') or (cbxcust.Items
[cbxcust.ItemIndex]='')
then wheresql:=''
else wheresql:='and (c.customer_name='''+cbxcust.Items
[cbxcust.itemindex]+')';
with datamodule2,qrydatecust do
begin
close;
SQL.clear;
sql.Add('select o.orderid,o.orderdate,c.customer_name');
sql.Add(',od.diam,od.length,od.num,od.pnum,od.plength');
sql.Add('from orders o,customer c ,orderdetail od where
(c.customerid=o.customerid)'''+wheresql+'''');
sql.Add('and (o.orderdate between'''+datetostr
(DateTimePicker1.datetime)+'''and'''+datetostr(DateTimePicker2.datetime)
+')''');
sql.Add('and (o.orderid=od.orderid)');
if prepared=false then prepare;
open;
end;
end;
说我的sql语句出错,请问高手们错在那里?
谢谢!wdsu@htc.net.cn