我把上面的写为 With adoQuery1 do begin SQL.Clear; sql.add('select * from 休假表 where datediff(month,假期时间至,'"& combobox1&"-"&combobox2&"-1')'); open; end; 可是老大,还是不行啊,编译都不能通过。
你用的delphi对吧?strSQL:='select * from 休假表 where datediff(month,假期时间至,'''+combobox1.Text+'-'+combobox2.Text+'-1'')';
sql.add('select * from 休假表 where datediff(month,假期时间至,'"& combobox1&"-"&combobox2&"-1')'); 改成: sql.add('select * from 休假表 where convert(varchar,'&combobox1&combobox2&01',102)=假期时间至''')
With adoQuery1 do
begin
SQL.Clear;
sql.add('select * from 休假表 where datediff(month,假期时间至,'"& combobox1&"-"&combobox2&"-1')');
open;
end;
可是老大,还是不行啊,编译都不能通过。
改成:
sql.add('select * from 休假表 where convert(varchar,'&combobox1&combobox2&01',102)=假期时间至''')