我用ACCESS数据库,做了一个BUTTON其代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
total:real;
begin
ADOQuery1.Active:=false;
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select 考号,yw,ywwc from cjb order by yw desc';
ADOQuery1.Open;
ADOQuery1.First;
ADOQuery1.Active:=false;
i:=1;
j:=1;
Total:=0.0;
while not ADOQuery1.Eof do
begin
if Total<>ADOQuery1.FieldByName('yw').Asfloat then
j:=i;
ADOQuery1.Close;
ADOQuery1.SQL.Text:='updata cjb set ywwc='+inttostr(j)+
' where 考号="'+ADOQuery1.FieldByName('考号').AsString+'"';
ADOQuery1.ExecSQL;
Total:=ADOQuery1.FieldByName('yw').Asfloat;
i:=i+1;
ADOQuery1.Next;
end;
end;能运行,但始没有结果,即ywwc中没有内,哪位大侠能帮忙改一下,感激不尽!!!!!!!
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
total:real;
begin
ADOQuery1.Active:=false;
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select 考号,yw,ywwc from cjb order by yw desc';
ADOQuery1.Open;
ADOQuery1.First;
ADOQuery1.Active:=false;
i:=1;
j:=1;
Total:=0.0;
while not ADOQuery1.Eof do
begin
if Total<>ADOQuery1.FieldByName('yw').Asfloat then
j:=i;
ADOQuery1.Close;
ADOQuery1.SQL.Text:='updata cjb set ywwc='+inttostr(j)+
' where 考号="'+ADOQuery1.FieldByName('考号').AsString+'"';
ADOQuery1.ExecSQL;
Total:=ADOQuery1.FieldByName('yw').Asfloat;
i:=i+1;
ADOQuery1.Next;
end;
end;能运行,但始没有结果,即ywwc中没有内,哪位大侠能帮忙改一下,感激不尽!!!!!!!
解决方案 »
- 关于进销存报表视图设计问题
- D7的ActionToolBar的问题,大家来看看
- 难 !!! delphi7调用 C 写的DLL 文件,我的 DLL 内函数和数据类型如下:
- 头疼死了,望大虾们指教!!
- 能很快实现这功能吗?点击 E_mail:[email protected]调用outlook发邮件
- 高手请进!~!!!!!!!!!有分相待!!!!!!!!!
- 請教 DBGrid 怎樣使一行中的,一個字段的Font.Color 改變
- 谁有DBTreeView控件?收到马上送50分!
- 在存储过程里,怎样用SQL语句实现以下功能?
- 如何得到系统的菜单?
- Delphi 调用 VC 写的 DLL 提示下列错误,跪求帮忙!
- 一个让我很困惑的问题?
begin
if Total <> ADOQuery1.FieldByName( 'yw ').Asfloat then
这里不要用同一个数据集
ADOQuery1.Close;
ADOQuery1.SQL.Text:= 'select 考号,yw,ywwc from cjb order by yw desc ';
ADOQuery1.Open;
ADOQuery1.First;
ADOQuery1.Active:=false; <=====你又把ADOQuery1关闭了!!!!
ADOQuery1.SQL.Text:= 'updata cjb set ywwc=……
我写错了:
ADOQuery1.SQL.Text:= 'update cjb set ywwc=……
并回复楼上:
不关闭不行啊!运行出错!