注册 登录
编程论坛 Delphi论坛

时间条件查询的问题?

yuutian 发布于 2010-11-17 14:17, 695 次点击
我想将lisbox中的时间作为条件
     进行查询
         代码如下
var
 r:integer;
begin
      for r:=0 to listbox2.Items.Count-1 do
      begin
          if listbox2.Selected[r] then
          with adoquery11 do
          begin
               close;
               sql.clear;
               sql.Add('select sessionid from sessionn where endtime='''+trim(listbox2.Items[r])+''' ');
               open;
               listbox1.Selected[r]:=true;
               z5:=fieldbyname('sessionid').AsInteger;
          end;
end;
end;
   
  总是显示错误:     标准表达式中的数据类型不匹配
  其中 endtime 是时间,listbox2中也是时间
1 回复
#2
ni__haha2010-12-09 08:13
楼主,你前面是listbox【2】,后面又是listbox【1】,这个有点不懂了,整体程序看上去没错,这行“sql.Add('select sessionid from sessionn where endtime='''+trim(listbox2.Items[r])+''' ');”感觉不对。
1