with mydata.ADOQemployee do
begin
close;
sql.Clear;
sql.add('select * from v_employee where (name is not null)'); if s_date_check.checked=false then
begin
sql.Add(' and inday >=:fromday and inday<:today');
decodedate(dtp_from.Date,v_year,v_month,v_day);
v_datefrom:=strtodate(inttostr(v_year) + '-' + inttostr(v_month) + '-' + inttostr(v_day));
decodedate(dtp_to.Date+1,v_year,v_month,v_day);
v_dateto:=strtodate(inttostr(v_year) + '-' + inttostr(v_month) + '-' + inttostr(v_day));
parameters.ParamByName('fromday').Value:=v_datefrom;
parameters.ParamByName('today').Value:=v_dateto;
end;
open;
end;上面这段语句是查询一段日期内的员工,但是老是说“ODBC SQL SERVER DRIVER 没有执行可选特性”,请各位帮帮忙,实在是没有办法了。
begin
close;
sql.Clear;
sql.add('select * from v_employee where (name is not null)'); if s_date_check.checked=false then
begin
sql.Add(' and inday >=:fromday and inday<:today');
decodedate(dtp_from.Date,v_year,v_month,v_day);
v_datefrom:=strtodate(inttostr(v_year) + '-' + inttostr(v_month) + '-' + inttostr(v_day));
decodedate(dtp_to.Date+1,v_year,v_month,v_day);
v_dateto:=strtodate(inttostr(v_year) + '-' + inttostr(v_month) + '-' + inttostr(v_day));
parameters.ParamByName('fromday').Value:=v_datefrom;
parameters.ParamByName('today').Value:=v_dateto;
end;
open;
end;上面这段语句是查询一段日期内的员工,但是老是说“ODBC SQL SERVER DRIVER 没有执行可选特性”,请各位帮帮忙,实在是没有办法了。
解决方案 »
- 如果把Byte类型的数组的内容不变全部显示在MEMO中
- 调试dpk包,有些单元可以设置跟踪断点有些不行,原因是什么?
- 托盘程序莫名自动退出
- 访问excel单元是老是CoInitialize has not been called??????????????
- 我被这个简单的问题搞晕了,大家来看看!
- [提问] 在Delphi或VB的程序里面怎么将这些符号显示出来☻☺♀♂☼♠♣♥♦♫
- 数据财出.
- 如何将String变量赋给TTable变量中字段呢?
- 怎么样做一个自己的打开报表的按钮?
- 可行的 简体转换繁体 程序
- 如何获取远程计算机的路径
- 让十六进制数 在 memo1 里显示成string类型,
' and inday >= '+ QuotedStr(FormatDateTime('yyyy-mm-dd',dtp_from.Date))+' and inday<' + QuotedStr(FormatDateTime('yyyy-mm-dd',dtp_to.Date+1));
我这种方式很方便调试, 我都很少用参数
FormDateTime('yyyy-mm-dd', Date);
var
strSQL: string;
begin
with mydata.ADOQemployee do begin
close;
sql.Clear;
strSQL := 'select * from v_employee where (name is not null) and inday>=''%s'' and inday<''%s''';
strSQL := Format(strSQL, [FormDateTime('yyyy-mm-dd', dtp_from.Date), FormDateTime('yyyy-mm-dd', dtp_to.Date)]);
SQL.Text := strSQL;
Open;
end;
用楼上不用参数直接传字符串的办法试一下,还不对的话把SQL语句取出来到查询分析器里试一下
if s_date_check.checked=false then
begin
sql.Add(' and inday >=:fromday and inday<:today');
parameters.ParamByName('fromday').Value:=dtp_to.Date;
parameters.ParamByName('today').Value:=dtp_to.Date+1;
end;
open;
如果inday字段是char类型
if s_date_check.checked=false then
begin
sql.Add(' and inday >=:fromday and inday<:today');
decodedate(dtp_from.Date,v_year,v_month,v_day);
v_datefrom:=inttostr(v_year) + '-' + inttostr(v_month) + '-' + inttostr(v_day));
decodedate(dtp_to.Date+1,v_year,v_month,v_day);
v_dateto:=inttostr(v_year) + '-' + inttostr(v_month) + '-' + inttostr(v_day);
parameters.ParamByName('fromday').Value:=v_datefrom;
parameters.ParamByName('today').Value:=v_dateto;
end;
open;