我的设计界面界面是这样的,那个日期用的是DateTimePicker1控件,其它几个都是文本。现在我是想要做查询功能,如果没有这个日期控件的话,我的代码如下(代码中文字有所出入):
try
str:='where(1=1)';
if combobox1.Text'' then str:=str+'and (所在系别 like'''+'%'+combobox1.Text+'%'')' ;
if edit3.Text'' then str:=str+'and (所在专业 like'''+'%'+edit3.Text+'%'')';
if edit1.Text'' then str:=str+'and (所在班级 like'''+'%'+edit1.Text+'%'')';
if edit4.Text'' then str:=str+'and (课程名称 like'''+'%'+edit4.Text+'%'')';
if edit2.Text'' then str:=str+'and (课程代号 like'''+'%'+edit2.Text+'%'')';
ADOquery1.Close;
ADOquery1.SQL.Clear;
ADoquery1.SQL.Add('select * from 课程资源表');
adoquery1.SQL.Add(str);
adoquery1.Open;
except
exit;
end
但是多了这个日期后我该怎么写这查询代码啊?或是说怎么添加进去。请高手指教。可行者再加分
我按你的代码试了下,可是这样查询不管怎么查都是说"你要查询的信息不存在".那个日期在数据库中的类型是文本,一开始是日期类型,可是这样会出错.改成文本后就查不到信息了.http://www.namipan.com/d/52cb8bd6e1f4e2ea4bb2d2d098629895001a21d1cfbf1700这是下载地址,你帮我调试一下.明天晚上我来向你拿.调试好了发我邮箱[email protected],只需帮我调试往来信息管理窗口的查询按钮就可以了.