U
ufo!
Unregistered / Unconfirmed
GUEST, unregistred user!
我在主程序中把ibsql2当参数传给dll,执行ibsql2.exequery时候提示访问内存错误。
而同样方式使用ibquery却正常。
我已经添加了sharemem单元。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ibsql,ibquery, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
Label7: TLabel;
Button5: TButton;
procedure FormShow(Sender: TObject);
procedure StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
ibsql1: tibsql;//声明一个变量,以接受传入的对象参数
ibquery1: tibquery;
zhiduan1,zdnr1: string; //接受传入的参数
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
var i: integer;
begin
i:= 1;
ibsql1.Close;
ibsql1.SQL.Clear;
ibsql1.SQL.Add('update ddb set khtel= ''567'' where ddh= '+'''' + zdnr1 +'''');
ibsql1.ExecQuery;
while not ibsql1.Eof do
begin
stringgrid1.Cells[0,i]:= ibsql1.fieldbyname('cph').AsString;
stringgrid1.Cells[1,i]:= inttostr(ibsql1.fieldbyname('shul').AsInteger);
stringgrid1.Cells[2,i]:= formatfloat('0.00',ibsql1.fieldbyname('djia').AsFloat);
stringgrid1.Cells[3,i]:= ibsql1.fieldbyname('miaos').AsString;
ibsql1.next;
i:= i+1;
stringgrid1.RowCount:= i;
stringgrid2.RowCount:= i;
end;
(* ibquery1.Close; //注释掉的这段可以正常运行
ibquery1.SQL.Clear;
ibquery1.SQL.Add('select cph,miaos,shul,djia from ddwp where ddh= '+'''' + zdnr1 +'''');
ibquery1.Open;
ibquery1.Last;
for i:= 1 to ibquery1.RecordCount do
begin
ibquery1.RecNo:= i;
stringgrid1.Cells[0,i]:= ibquery1.fieldbyname('cph').AsString;
stringgrid1.Cells[1,i]:= inttostr(ibquery1.fieldbyname('shul').AsInteger);
stringgrid1.Cells[2,i]:= formatfloat('0.00',ibquery1.fieldbyname('djia').AsFloat);
stringgrid1.Cells[3,i]:= ibquery1.fieldbyname('miaos').AsString;
//ibsql1.next;
//i:= i+1;
stringgrid1.RowCount:= i+2;
stringgrid2.RowCount:= i+2;
end; *)
end;
而同样方式使用ibquery却正常。
我已经添加了sharemem单元。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ibsql,ibquery, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
Label7: TLabel;
Button5: TButton;
procedure FormShow(Sender: TObject);
procedure StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
ibsql1: tibsql;//声明一个变量,以接受传入的对象参数
ibquery1: tibquery;
zhiduan1,zdnr1: string; //接受传入的参数
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
var i: integer;
begin
i:= 1;
ibsql1.Close;
ibsql1.SQL.Clear;
ibsql1.SQL.Add('update ddb set khtel= ''567'' where ddh= '+'''' + zdnr1 +'''');
ibsql1.ExecQuery;
while not ibsql1.Eof do
begin
stringgrid1.Cells[0,i]:= ibsql1.fieldbyname('cph').AsString;
stringgrid1.Cells[1,i]:= inttostr(ibsql1.fieldbyname('shul').AsInteger);
stringgrid1.Cells[2,i]:= formatfloat('0.00',ibsql1.fieldbyname('djia').AsFloat);
stringgrid1.Cells[3,i]:= ibsql1.fieldbyname('miaos').AsString;
ibsql1.next;
i:= i+1;
stringgrid1.RowCount:= i;
stringgrid2.RowCount:= i;
end;
(* ibquery1.Close; //注释掉的这段可以正常运行
ibquery1.SQL.Clear;
ibquery1.SQL.Add('select cph,miaos,shul,djia from ddwp where ddh= '+'''' + zdnr1 +'''');
ibquery1.Open;
ibquery1.Last;
for i:= 1 to ibquery1.RecordCount do
begin
ibquery1.RecNo:= i;
stringgrid1.Cells[0,i]:= ibquery1.fieldbyname('cph').AsString;
stringgrid1.Cells[1,i]:= inttostr(ibquery1.fieldbyname('shul').AsInteger);
stringgrid1.Cells[2,i]:= formatfloat('0.00',ibquery1.fieldbyname('djia').AsFloat);
stringgrid1.Cells[3,i]:= ibquery1.fieldbyname('miaos').AsString;
//ibsql1.next;
//i:= i+1;
stringgrid1.RowCount:= i+2;
stringgrid2.RowCount:= i+2;
end; *)
end;