W
wchal
Unregistered / Unconfirmed
GUEST, unregistred user!
我有兩段代碼
一、
SQ:='select distinct TM from JGZLK where (JZ= :JZ)and(DATE1>= 1)and(DATE2<= 2)';
ADODataSet1.Close;
ADODataSet1.commandText:=SQ;
ADODataSet1.Parameters.ParamByName('JZ').Value:='ABC';
ADODataSet1.Parameters.ParamByName('D1').Value:=strtodate(datetostr(datetimepicker1.Date));
ADODataSet1.Parameters.ParamByName('D2').Value:=strtodate(datetostr(datetimepicker1.Date+1));
ADODataSet1.Open;
ShowMessage('數:'+inttostr(ADODataSet1.RecordCount));
二、
SQ:='select TM from YJJDK where (TM in(select TM from JGZLK where (JZ= :JZ)and(DATE1>= 1)and(DATE2<= 2)))';
ADODataSet1.Close;
ADODataSet1.commandText:=SQ;
ADODataSet1.Parameters.ParamValues['JZ']:='ABC';
ADODataSet1.Parameters.ParamValues['D1']:=datetimepicker1.Date;
ADODataSet1.Parameters.ParamValues['D2']:=datetimepicker1.Date+1;
ADODataSet1.Open;
ShowMessage('計:'+inttostr(ADODataSet1.RecordCount));
當程序啟動后,只要先執行過第一段再執行第二段,那麼第二段結果正確.
但如直接執行第二段結果就不對了.
為什麼啊?
一、
SQ:='select distinct TM from JGZLK where (JZ= :JZ)and(DATE1>= 1)and(DATE2<= 2)';
ADODataSet1.Close;
ADODataSet1.commandText:=SQ;
ADODataSet1.Parameters.ParamByName('JZ').Value:='ABC';
ADODataSet1.Parameters.ParamByName('D1').Value:=strtodate(datetostr(datetimepicker1.Date));
ADODataSet1.Parameters.ParamByName('D2').Value:=strtodate(datetostr(datetimepicker1.Date+1));
ADODataSet1.Open;
ShowMessage('數:'+inttostr(ADODataSet1.RecordCount));
二、
SQ:='select TM from YJJDK where (TM in(select TM from JGZLK where (JZ= :JZ)and(DATE1>= 1)and(DATE2<= 2)))';
ADODataSet1.Close;
ADODataSet1.commandText:=SQ;
ADODataSet1.Parameters.ParamValues['JZ']:='ABC';
ADODataSet1.Parameters.ParamValues['D1']:=datetimepicker1.Date;
ADODataSet1.Parameters.ParamValues['D2']:=datetimepicker1.Date+1;
ADODataSet1.Open;
ShowMessage('計:'+inttostr(ADODataSet1.RecordCount));
當程序啟動后,只要先執行過第一段再執行第二段,那麼第二段結果正確.
但如直接執行第二段結果就不對了.
為什麼啊?