用ADOQuery控件怎么进行数据的查询

liyong128 2004-07-29 02:35:16
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
str:=dbcombobox1.Text;
with adoquery1 do
begin
connection:=adoconnection1;
close;

SQL.Add('select * from rtu');
sql.Add('where rtu_id=str');
execsql; //出错的地方 提示STR参数没有默认值
open;
end;
...全文
138 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fanhaili 2004-07-29
  • 打赏
  • 举报
回复
你的RTU_ID是什么类型呀??如果是字符型,必须加引号
liyong128 2004-07-29
  • 打赏
  • 举报
回复
谢谢各位了,还有我选择一个值,在点击它为什么报错。

语言错误,在查询表达式中RTU_ID=一个值,而在select * from rtu where rtu_id=另一个值
chwdong 2004-07-29
  • 打赏
  • 举报
回复
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
str:=dbcombobox1.Text;
with adoquery1 do
begin
close;
connection:=adoconnection1;
SQL.Add('select * from rtu ');//注意最后有个空格
sql.Add('where rtu_id='+quotestr(str));
open;
end;
lcxhjg 2004-07-29
  • 打赏
  • 举报
回复
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
str:=dbcombobox1.Text;
with adoquery1 do
begin
close;
connection:=adoconnection1; //这里也要调整一下
SQL.Add('select * from rtu');
sql.Add('where rtu_id=str');
//去掉 execsql;(execsql不返回数据集,active:=True;或open返回数据集)
open;
end;

YAMABACK 2004-07-29
  • 打赏
  • 举报
回复
execsql与 open的区别在于:execsql执行后不会返回数据集,而open返回数据集
bluesky23 2004-07-29
  • 打赏
  • 举报
回复
execsql;
open;
这两条语句冲突。
303 2004-07-29
  • 打赏
  • 举报
回复
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
str:=dbcombobox1.Text;
with adoquery1 do
begin
connection:=adoconnection1;
close;

SQL.Add('select * from rtu');
sql.Add('where rtu_id='+quotedstr(str));
// execsql; //出错的地方 提示STR参数没有默认值
//上面的这行可以不用吧!!!因为下面有Open了。

open;
end;

liyong128 2004-07-29
  • 打赏
  • 举报
回复
我自己先顶一下

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧