请帮我看看下面的程序哪儿有错!!
程序编译时能通过.在执行时总是出现异常(too few paramters)!!
我用的是ACCESS 2000 ,ODBC
procedure Tyexport.Button1Click(Sender: TObject);
var
str:string;
begin
if (checkbox1.Checked=false) and (checkbox2.Checked=false) then
begin
showmessage('请选择查询条件');
end
else
begin
DataSource1.DataSet:=Query1;
Dbgrid1.DataSource:=Datasource1;
with Query1 do
begin
DatabaseName:='ypgl';
close;
sql.clear;
str:='select * from rkb ' ;
if checkbox1.Enabled=true then
begin
str:=str+'where chdw=combobox1.text';
end;
if checkbox2.Checked=true then
begin
str:=str+'where xsrq=datetostr(datetimepicker1.date)';
end;
if (checkbox1.Checked=true ) and checkbox2.Checked=true then
begin
str:=str+'where xsrq=datetostr(datetimepicker1.date) and chdw=combobox1.text';
end;
sql.add(str);
prepare;
open;
end;
end;
end;
程序编译时能通过.在执行时总是出现异常(too few paramters)!!
我用的是ACCESS 2000 ,ODBC
procedure Tyexport.Button1Click(Sender: TObject);
var
str:string;
begin
if (checkbox1.Checked=false) and (checkbox2.Checked=false) then
begin
showmessage('请选择查询条件');
end
else
begin
DataSource1.DataSet:=Query1;
Dbgrid1.DataSource:=Datasource1;
with Query1 do
begin
DatabaseName:='ypgl';
close;
sql.clear;
str:='select * from rkb ' ;
if checkbox1.Enabled=true then
begin
str:=str+'where chdw=combobox1.text';
end;
if checkbox2.Checked=true then
begin
str:=str+'where xsrq=datetostr(datetimepicker1.date)';
end;
if (checkbox1.Checked=true ) and checkbox2.Checked=true then
begin
str:=str+'where xsrq=datetostr(datetimepicker1.date) and chdw=combobox1.text';
end;
sql.add(str);
prepare;
open;
end;
end;
end;
解决方案 »
- sql 语句问题。出勤统计的表
- 同一个FORM中多个frame中设置相同的快捷键的问题
- 江湖救急!!!!关于全文检索引擎安装的问题
- Delphi中Flash播放ActiveX控件ShockwaveFlash的问题![急]
- 如何删除不用的应用程序服务器,它们保存在什么地方?
- 如果我在数据库里的一个field里面放的是0,1,2,3四种数字,而我要在dbgrid里面对应显示的是的市内,省内,省外,国外四种,怎么办
- delphi如何实现对表的从新排序,紧急
- 自定义报表预览时,如何按点一下鼠标便放大或缩小?qrpreview控件
- 如何获取Window98登录用户的[登录密码]???
- 在记录里面怎么定义若干比特个比特的变量?
- 高分寻求delphi经典代码,思想 外加
- 求高速公路收费系统软件:分数可以商量(我一共有3685分)!!!
應為:
str:=str + 'where chdw=' + '''' + combobox1.text + '''';str:=str+'where xsrq=datetostr(datetimepicker1.date)';
應為:
str:=str + 'where xsrq=' + '''' + datetostr(datetimepicker1.date) + ''''';
var
str:string;
begin
if (checkbox1.Checked=false) and (checkbox2.Checked=false) then
begin
showmessage('请选择查询条件');
end
else
begin
DataSource1.DataSet:=Query1;
Dbgrid1.DataSource:=Datasource1;
with Query1 do
begin
DatabaseName:='ypgl';
close;
sql.clear;
str:='select * from rkb ' ;
if checkbox1.Enabled=true then
begin
str:=str+'where chdw=combobox1.text';//error//str:=str+'where chdw='''+combobox1.text+'''';//后面还有许多类似的错误
end;
if checkbox2.Checked=true then
begin
str:=str+'where xsrq=datetostr(datetimepicker1.date)';
end;
if (checkbox1.Checked=true ) and checkbox2.Checked=true then
begin
str:=str+'where xsrq=datetostr(datetimepicker1.date) and chdw=combobox1.text';
end;
sql.add(str);
prepare;
open;
end;
end;
end;