时间查询 用了下面几种方法 都报错 "不完整的定义"
请高手执教
sqlStr:='Select LockID from UnLockAndLockTemp where UnLockID ='+ '''' + strUnLockID + '''' +
// ' and GrantDate =' + '#' +DateTimeToStr(grantDateTime) + '#';
// ' and GrantDate = #' + grantDateTime + '#';
//' and GrantDate =' + '#' + FormatDateTime('yyyy-MM-dd HH:mm:ss', grantDateTime) + '#';
' and GrantDate = ' + 'CDate(' + '2006-10-2 10:22:21' + ')';
请高手执教
sqlStr:='Select LockID from UnLockAndLockTemp where UnLockID ='+ '''' + strUnLockID + '''' +
// ' and GrantDate =' + '#' +DateTimeToStr(grantDateTime) + '#';
// ' and GrantDate = #' + grantDateTime + '#';
//' and GrantDate =' + '#' + FormatDateTime('yyyy-MM-dd HH:mm:ss', grantDateTime) + '#';
' and GrantDate = ' + 'CDate(' + '2006-10-2 10:22:21' + ')';
//另一个查询条件,你自己添加进字串里(我被''''''''搞得有点晕,所以没敢乱复制)
sqlstr:String;
begin
sqlstr:='Select LockID from UnLockAndLockTemp where GrantDate=:GrantDate';
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add(sqlstr);
Parameters.parambyname('GrantDate').Value:=now;
open;
end;
var
sqlstr:String;
begin
sqlstr:='Select LockID from UnLockAndLockTemp where GrantDate=:GrantDate';
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add(sqlstr);
Parameters.parambyname('GrantDate').Value:=now;
open;
end;