主程序rkybbfm.quickrep1.previe调用以下表单出错
unit ybb;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ComCtrls, ExtCtrls, DB, ADODB, QuickRpt,
QRCtrls, Grids, DBGrids;type
Trkybbfm = class(TForm)
Panel1: TPanel;
ADOQuery: TADOQuery;
QuickRep1: TQuickRep;
TitleBand1: TQRBand;
DetailBand1: TQRBand;
PageHeaderBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
QRLabel9: TQRLabel;
clbh: TQRMemo;
clmc: TQRMemo;
pl: TQRMemo;
sl: TQRMemo;
zje: TQRMemo;
rq: TQRMemo;
jhr: TQRMemo;
QRLabel10: TQRLabel;
zbrq: TQRLabel;
zsl: TQRLabel;
zgje: TQRLabel;
connybb: TADOConnection;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
rkybbfm: Trkybbfm;implementationuses mainut,dataut;{$R *.dfm}procedure Trkybbfm.FormCreate(Sender: TObject);
var
str:string;
Present,Present1: TDateTime;
Year, Month, Day,year1, Month1, Day1: Word;
sumje,sumsl:integer;
begin
sumje:=0;
sumsl:=0;
ADOquery.ConnectionString:='Provider=OraOLEDB.Oracle.1;Password=snow;Persist Security Info=True;User ID=system;Data Source=xlsc';
ADOquery.active:=false;
zbrq.Caption:=datetostr(date());
with adoquery do--------------------------错在这里检测到错误类EAccessViolation 存取地址0051D830违例发生在模块main.exe中 读在地址00000300里 我该怎么修改啊?begin
close;
sql.Clear;
sql.Add('select * from rkb');
open;
present:=fieldbyname('入库日期').AsDateTime;
DecodeDate(Present, Year, Month, Day);
present1:=now;
DecodeDate(Present1, Year1, Month1, Day1);
first;
while not eof do
begin
if (month=month1) and (year1=year) then
begin
clbh.Lines.Add(fieldbyname('材料编号').AsString);
clmc.Lines.Add(fieldbyname('材料名称').AsString);
pl.Lines.Add(fieldbyname('品类').AsString);
sl.Lines.Add(fieldbyname('数量').AsString);
zje.Lines.Add(fieldbyname('总金额').AsString);
rq.Lines.Add(fieldbyname('入库日期').AsString);
jhr.Lines.Add(fieldbyname('进货人').AsString);
sumje:=sumje+fieldbyname('总金额').AsInteger;
sumsl:=sumsl+fieldbyname('数量').AsInteger;
end;
next;
end;
zsl.Caption:='总数量:'+inttostr(sumsl);
zgje.Caption:='总金额:'+inttostr(sumje);
end;
end;end.
unit ybb;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ComCtrls, ExtCtrls, DB, ADODB, QuickRpt,
QRCtrls, Grids, DBGrids;type
Trkybbfm = class(TForm)
Panel1: TPanel;
ADOQuery: TADOQuery;
QuickRep1: TQuickRep;
TitleBand1: TQRBand;
DetailBand1: TQRBand;
PageHeaderBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
QRLabel9: TQRLabel;
clbh: TQRMemo;
clmc: TQRMemo;
pl: TQRMemo;
sl: TQRMemo;
zje: TQRMemo;
rq: TQRMemo;
jhr: TQRMemo;
QRLabel10: TQRLabel;
zbrq: TQRLabel;
zsl: TQRLabel;
zgje: TQRLabel;
connybb: TADOConnection;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
rkybbfm: Trkybbfm;implementationuses mainut,dataut;{$R *.dfm}procedure Trkybbfm.FormCreate(Sender: TObject);
var
str:string;
Present,Present1: TDateTime;
Year, Month, Day,year1, Month1, Day1: Word;
sumje,sumsl:integer;
begin
sumje:=0;
sumsl:=0;
ADOquery.ConnectionString:='Provider=OraOLEDB.Oracle.1;Password=snow;Persist Security Info=True;User ID=system;Data Source=xlsc';
ADOquery.active:=false;
zbrq.Caption:=datetostr(date());
with adoquery do--------------------------错在这里检测到错误类EAccessViolation 存取地址0051D830违例发生在模块main.exe中 读在地址00000300里 我该怎么修改啊?begin
close;
sql.Clear;
sql.Add('select * from rkb');
open;
present:=fieldbyname('入库日期').AsDateTime;
DecodeDate(Present, Year, Month, Day);
present1:=now;
DecodeDate(Present1, Year1, Month1, Day1);
first;
while not eof do
begin
if (month=month1) and (year1=year) then
begin
clbh.Lines.Add(fieldbyname('材料编号').AsString);
clmc.Lines.Add(fieldbyname('材料名称').AsString);
pl.Lines.Add(fieldbyname('品类').AsString);
sl.Lines.Add(fieldbyname('数量').AsString);
zje.Lines.Add(fieldbyname('总金额').AsString);
rq.Lines.Add(fieldbyname('入库日期').AsString);
jhr.Lines.Add(fieldbyname('进货人').AsString);
sumje:=sumje+fieldbyname('总金额').AsInteger;
sumsl:=sumsl+fieldbyname('数量').AsInteger;
end;
next;
end;
zsl.Caption:='总数量:'+inttostr(sumsl);
zgje.Caption:='总金额:'+inttostr(sumje);
end;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货