请问为什么I循环?如何改才对?在线等谢了
Cnt:=100with Q1 do
  begin
      sql.Clear;
      SQL.Add('Select * from AA ');
      Open;
      while not eof do
      begin
            for  I:=0  to Cnt-1 do
            begin
                point[I].X:=FieldValues['字段1'];
                point[I].Y:=FieldValues['字段2'];
            end;
            next;             
      end;
      polybezier(h,point,Cnt);  end;

解决方案 »

  1.   

    不是I循环了吧,应该是
    with Q1 do
      begin
          sql.Clear;
          SQL.Add('Select * from AA ');
          Open;
          while not eof do
          begin
                for  I:=0  to Cnt-1 do
                begin
                    point[I].X:=FieldValues['字段1'];
                    point[I].Y:=FieldValues['字段2'];
                end;
               polybezier(h,point,Cnt); //-----            next;             
          end;
    //      polybezier(h,point,Cnt);  end;
      

  2.   

    你放在while 之后画,就变成永远只画最后一个BEZIER曲线了
      

  3.   

    代码贴完整了吗?不过看你的代码愿意最少应该把那个polybezier(h,point,Cnt);移动到NEXT之前
      

  4.   

    结果出现内存出错?全部代码如下:----------------------------------------------------------------------------------》
    type
      TLinesForm = class(TForm)
        Button1: TButton;
        StatusBar1: TStatusBar;
        Button2: TButton;
        Conn: TADOConnection;
        Q1: TADOQuery;
        Ds_Q1: TDataSource;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      LinesForm: TLinesForm;implementation{$R *.dfm}//取得SQL返回语句
    function GetSQL(ColStr:String;SqlStr:String):String ;
    begin
        Result:='';
        with LinesForm.Q1 do
        begin
            SQL.Clear;
            SQL.Add(SqlStr);
            Open;
            If RecordCount>0 then
                Result:=VarToStr(FieldValues[ColStr])
            else
                Result:='';
        end;
    end;procedure TLinesForm.Button1Click(Sender: TObject);
    var
        point:array[0..6] of Tpoint;
        h:HDC;
        I:Integer;
        Cnt:Integer;
    begin
      h:=getdc(LinesForm.handle);   
      {point[0].x:=25;   point[0].y:=25;
      point[1].x:=35;   point[1].y:=170;   
      point[2].x:=130;point[2].y:=120;   
      point[3].x:=150;point[3].y:=150;   
      point[4].x:=170;point[4].y:=280;   
      point[5].x:=250;point[5].y:=115;   
      point[6].x:=250;point[6].y:=225;}
      Cnt:=StrToInt(GetSQL('Cnt','Select Count(*)as Cnt from AA'));  with Q1 do
      begin
        sql.Clear;
        SQL.Add('Select * from AA ');
        Open;
        while not eof do
        begin
              for  I:=0  to Cnt-1 do
              begin
                  point[I].X:=FieldValues['字段1'];
                  point[I].Y:=FieldValues['字段2'];
              end;
             polybezier(h,point,Cnt); //-----          next;
        end;
      end;
       
    end;   
      

  5.   

    呵呵,原来你的CNT就是数据库记录条数.
    那就不需要用FOR循环了,还有就是你的POINT的声明有问题了应该是一个动态的var
        point:array  of Tpoint;  //<-----------------------------
        h:HDC;
        I:Integer;
        Cnt:Integer;           
    begin
      h:=getdc(LinesForm.handle);   
      {point[0].x:=25;   point[0].y:=25;
      point[1].x:=35;   point[1].y:=170;   
      point[2].x:=130;point[2].y:=120;   
      point[3].x:=150;point[3].y:=150;   
      point[4].x:=170;point[4].y:=280;   
      point[5].x:=250;point[5].y:=115;   
      point[6].x:=250;point[6].y:=225;}
      Cnt:=StrToInt(GetSQL('Cnt','Select Count(*)as Cnt from AA'));
      setlength(point,Cnt);
      i := 0;
      with Q1 do
      begin
        sql.Clear;
        SQL.Add('Select * from AA ');
        Open;
        while not eof do
        begin
           point[I].X:=FieldValues['字段1'];
           point[I].Y:=FieldValues['字段2'];
           inc(i)            //<-----------------------------------
           next;
        end;
        polybezier(h,point,Cnt); 
      end;
       
    end;
      

  6.   

    另外, 如果只是为了拿出记录数, 可以直接使用Q1.RECORDCOUNT
    同时为了可以正常释放应该使用
    setlength(point,cnt)
    try
    ....finally
      setlength(point,0);
    end;
      

  7.   


    出现了access violation at 0x000000b7:read of address 0x000000b7.Stopped.Use Step or Run to Continue.的错误。
    --------------------------------------------------------------------------
    procedure TLinesForm.Button1Click(Sender: TObject);
    var
        point:array[0..6] of Tpoint;
        h:HDC;
        I,J:Integer;
        Cnt:Integer;
    begin
      
      h:=getdc(LinesForm.handle);
      i := 0;
      with Q1 do
      begin
        sql.Clear;
        SQL.Add('Select * from AA ');
        Open;
        while not eof do
        begin
           point[I].X:=FieldValues['字段1'];
           point[I].Y:=FieldValues['字段2'];
           inc(i);        //
           polybezier(h,point,RecordCount); 
           next;
        end;
        
      end;procedure TLinesForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
    var
        P:TPoint;
        h:HDC;
    begin
        h:=getdc(LinesForm.handle);    
        GetCursorPos(p);  //获取屏幕的坐标
        Windows.ScreenToClient(h,p);  //转成窗口的坐标,h是窗口句柄
        StatusBar1.Panels[0].Text:='X:='+IntToStr(P.X)+' '+'Y:='+IntToStr(P.Y);
    end;end.
      

  8.   

    如果你不用动态数组那么
    begin
      
      h:=getdc(LinesForm.handle);
      i := 0;
      with Q1 do
      begin
        sql.Clear;
        SQL.Add('Select * from AA ');
        Open;
        while not eof do
        begin
           point[I].X:=FieldValues['字段1'];     //<-----------你要判断i是不是大于6啊
           point[I].Y:=FieldValues['字段2'];
           inc(i);        //
           polybezier(h,point,RecordCount); 
           next;
        end;
        
      end;你不判断,如果i >6 那point[7]是肯定要出错了啊.
      

  9.   

    还有       polybezier(h,point,RecordCount); 就不要放到循环里面的吧,
      

  10.   

    解决了那个溢出的问题材。。但按您的方式把polybezier(h,point,RecordCount); 放到外面,一样是画不到东西啊?不然你可以试一下什么都没画出来
      

  11.   

    问题挺多的,,,唉可是并不是能接受所有的数据,有的数据一画就了现以下之类的错误是不是那个函数有限制的。出现了access violation at 0x00000150:read of address 0x00000150.Stopped.Use Step or Run to Continue.的错误。
      

  12.   

    你可以在IDE下调试,看看出错的是哪行代码