dataset not in edit or insert mode

qq370465448 2009-12-06 08:07:24
procedure TForm3.Button2Click(Sender: TObject);
begin
adoquery1.Edit;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from fs where xh="'+dbtext1.Caption+'"');
adoquery1.open;
adoquery1.Active:=true;
if str<>'' then
adoquery1.FieldByName('str').AsString:=str;
end;

我是delphi新手,不知道为什么出在哪里?一按确定就弹出dataset not in edit or insert mode
哪位大哥可以帮我解决一下
...全文
578 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
coderee 2009-12-07
  • 打赏
  • 举报
回复
路过。
npkaida 2009-12-07
  • 打赏
  • 举报
回复

对不起,少了一个 Edit
procedure TForm3.Button2Click(Sender: TObject);
begin
adoquery1.Close; //等同于 adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from fs where xh="'+dbtext1.Caption+'"');
adoquery1.open; //等同于 adoquery1.Active:=true;
if str <>'' then
begin
adoquery1.Edit;
adoquery1.FieldByName('str').AsString:=str;
adoquery1.Post;
end;
end;

lyhoo163 2009-12-07
  • 打赏
  • 举报
回复
up
汉语很 2009-12-07
  • 打赏
  • 举报
回复
顺序搞错了
suuuu 2009-12-07
  • 打赏
  • 举报
回复
procedure TForm3.Button2Click(Sender: TObject);
begin
adoquery1.Close; //等同于 adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from fs where xh="'+dbtext1.Caption+'"');
adoquery1.open; //等同于 adoquery1.Active:=true;
if str <>'' then
begin
adoquery1.Edit;//如果你想做插入动作的话这里改为 adoquery1.append
adoquery1.FieldByName('str').AsString:=str;
adoquery1.Post;
end;
end;
hwill 2009-12-06
  • 打赏
  • 举报
回复
procedure TForm3.Button2Click(Sender: TObject);
begin
adoquery1.Close; //等同于 adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from fs where xh="'+dbtext1.Caption+'"');
adoquery1.open; //等同于 adoquery1.Active:=true;
if str <>'' then
begin
adoquery1.Edit; //进入编辑状态
adoquery1.FieldByName('str').AsString:=str; //也可以写成adoquery1['str']:=str;
adoquery1.Post; //保存编辑结果
end;
end;
思远周 2009-12-06
  • 打赏
  • 举报
回复
顺序搞错了!如果要对数据进行修改,必须先要打开数据源,这样才可以进行操作!不然是不可以对数据进行edit,Append等操作的!希望人兄好好学习一下Ado控件的使用!
npkaida 2009-12-06
  • 打赏
  • 举报
回复

procedure TForm3.Button2Click(Sender: TObject);
begin
adoquery1.Close; //等同于 adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from fs where xh="'+dbtext1.Caption+'"');
adoquery1.open; //等同于 adoquery1.Active:=true;
if str <>'' then
begin
adoquery1.FieldByName('str').AsString:=str;
adoquery1.Post;
end;
end;


fa_ge 2009-12-06
  • 打赏
  • 举报
回复

procedure TForm3.Button2Click(Sender: TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from fs where xh="'+dbtext1.Caption+'"');
adoquery1.open;
adoquery1.Edit;
if str <>'' then
adoquery1.FieldByName('str').AsString:=str;
end;

2,507

社区成员

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

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