在ADOCommand中使用‘UpDate’修改记录?

Edman 2005-03-04 11:26:31
在ADOCommand中使用‘UpDate’修改记录,带参数时提示错误,出错代码如下:
with ADOComKL do
begin
CommandText:='Update YHB set 用户口令= :NKL where 用户名= :Username';
Parameters.Clear;
Parameters.ParamValues['NKL']:=Trim(Edit2.Text);
Parameters.ParamValues['Username']:=LogUn.userID;
Prepared:=True;
Execute;
end;
编译时弹出对话框提示如下:
  Debugger Exception Notification
Project GZRB.exe raised exception class EDatabaseError with Message
'ADOComKL:Parameter 'NKL'not Found'.Process stopped.Use Step or Run to Continue.
望告知如何解决,谢谢。
...全文
242 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
luckyboyforever 2005-03-23
  • 打赏
  • 举报
回复
post是干什么用的??
HWHuang 2005-03-23
  • 打赏
  • 举报
回复
post就是将修改过的资料在数据库中保存刷新。
Edman 2005-03-04
  • 打赏
  • 举报
回复
谁能说说ADOCommand的运行机制?
yiyideyi 2005-03-04
  • 打赏
  • 举报
回复
TADOCommand只能执行SQL语句,所以要用Execute来配合使用。
Edman 2005-03-04
  • 打赏
  • 举报
回复
chinaandys(降龙十八炒) ,首先谢谢你。
不过你改的那段代码我也早试过了,一样的提示;
这样的问题有什么思路解决?
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
with ADOComKL do
begin
Parameters.Clear;
CommandText:='Update YHB set 用户口令= :NKL where 用户名= :Username';

Parameters.ParamValues['NKL']:=Trim(Edit2.Text);
Parameters.ParamValues['Username']:=LogUn.userID;
Prepared:=True;
Execute;
end;
Edman 2005-03-04
  • 打赏
  • 举报
回复
我用的是Delphi7+Access;
在线等待!
yiyideyi 2005-03-04
  • 打赏
  • 举报
回复
更新数据库数据的话用TADOQuery控件吧,那个用Post就行了。
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
with ADOComKL do
begin
close;
Parameters.Clear;
CommandText:='Update YHB set 用户口令=:NKL where 用户名=:Username';
refresh; //刷新一下:
Parameters.ParamValues['NKL']:=Trim(Edit2.Text);
Parameters.ParamValues['Username']:=LogUn.userID;
Prepared:=True;
Execute;
end;
chinaandys 2005-03-04
  • 打赏
  • 举报
回复
写成这样:
procedure TForm1.Button1Click(Sender: TObject);
begin

with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from t_type where 商品代码=:ak' ); //参数这里不要加空格
Parameters.ParamByName('ak').Value:=trim(edit1.Text);
open;
end;
end;
Edman 2005-03-04
  • 打赏
  • 举报
回复
谢谢关注,不过问题还是没有解决;
各位如果使用ADO连接数据库的话是怎么更新数据的呀?
在哪个组件里用Update命令?
caiso 2005-03-04
  • 打赏
  • 举报
回复
顶一下
neo40 2005-03-04
  • 打赏
  • 举报
回复
ADOConnection1.Execute('Update YHB set 用户口令=' + Trim(Edit2.Text) + ' where 用户名=' + LogUn.userID);

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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