for int1:= 0 to ADOQuery1.RecordCount-1 do
begin
with ADOQuery1 do
begin
Close;
SQL.Clear;
new_1:=5656;
SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+' where 夹直线方向角_输入='+inttos(new_1));
ExecSQl;
Next;
就是想修改某一列的值,可老是报错
begin
with ADOQuery1 do
begin
Close;
SQL.Clear;
new_1:=5656;
SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+' where 夹直线方向角_输入='+inttos(new_1));
ExecSQl;
Next;
就是想修改某一列的值,可老是报错
SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+' where 夹直线方向角_输入='+inttostr(new_1));
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from [线路水平数据$]');
ADOQuery1.Open;new_1:=ADOQuery1.fieldbyname('夹直线方向角_输入').AsInteger;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+' where 夹直线方向角_输入='+inttostr(new_1));
ADOQuery1.ExecSQL;
begin
with ADOQuery2 do //這裏再用一個 AdoQuery2 . 不要用 AdoQuery1. 相同類型的變量你用WITH覺得舒服嗎?。呵呵,這樣好難分
begin
Close;
SQL.Clear;
new_1:=5656;
SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+' where 夹直线方向角_输入='+inttos(new_1));
ExecSQl;
Next;
// 認真看了下,你的ADOQuery1 根本沒有用。
with ADOQuery2 do
begin
Close;
SQL.Clear;
new_1:=5656;
SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+' where 夹直线方向角_输入='+inttos(new_1));
ExecSQl;
end;
我从昨天到现在都试了n种方法了 都不行 太打击了
你的FOR就沒有作用。你再看下的更新代碼好像是死的吧,那再多個FOR也是一樣的
通常FOR我們可以這樣寫:if not AdoQuery1.isEmpty then begin
with AdoQuery1 do while not eof do begin
////
next;
end;
end;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from [线路水平数据$]');
adoquery1.Open;new_1:=adoquery1.fieldbyname('夹直线方向角_输入').AsInteger;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update [线路水平数据$] set 夹直线方向角='+inttostr(new_1)+'where 夹直线方向角_输入='+inttostr(new_1));
adoquery1.ExecSQL;我现在把它改成最简单的update怎么还有问题啊?还是这个错误:操作必须是一个可更新的查询
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update [线路水平数据$] set [夹直线方向角]='+inttostr(new_1)+'where [夹直线方向角_输入]='+inttostr(new_1));
adoquery1.ExecSQL;