本人做毕业设计,但是现在有两个地方出现错误,改了,好久了,一直没法弄正确,郁闷死了,希望大家帮忙解决下啊,出错的具体代码如下:
盘点的代码,错误提示为:project superet.exe raised exception class edatabaseerror with message 'dbedit2:field'sell_number'not found'.
但是dbedit2是再另一个窗体中用于连接sells表的sell_number列的,和当前窗体没联系的
if (usertype<>'系统管理员') then
begin
messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
exit;
end;
unitdata.sells.Close;//与数据库中的销售记录表相连接,sells是ADOQuery的名称,也是销售记录表
unitdata.sells.SQL.Clear;
unitdata.sells.SQL.Add('select sum(product_price*sell_number) as total from sells where year(sell_time)=year(getdate())');//出错的地方
unitdata.sells.Open;
messagebox(handle,PChar('本年度销售额为 '+unitdata.sells.FieldByName('total').AsString+' 元。'),'年度盘点',MB_ICONinformation+mb_ok);
销售分析的代码,错误提示为:project superet.exe raised exception class edatabaseerror with message 'dbedit5:field'pro_stock'not found'.
但是dbedit5是再另一个窗体中用于连接products表的pro_stock列的,和当前窗体没联系的
var
i: integer;
begin
With Series1 do
Begin
unitdata.products.Close;
unitdata.products.SQL.Clear;
unitdata.products.SQL.Add('select distinct pro_name from products');
unitdata.products.Open; for i:=1 to unitdata.products.RecordCount do//出错的地方
begin
unitdata.sells.Close;
unitdata.sells.SQL.Clear;
unitdata.sells.SQL.Add('select sum(sell_number) as number from sells where product_name='+unitdata.products.FieldByName('pro_name').AsString);
unitdata.sells.Open;
Add(unitdata.sells.FieldByName('number').AsInteger,unitdata.products.FieldByName('pro_name').AsString,random(100000));
end;
end;
end;
我想这两个错误应该属于同一类型的,都是一样的报错,希望大家帮帮忙啊,万分感谢
盘点的代码,错误提示为:project superet.exe raised exception class edatabaseerror with message 'dbedit2:field'sell_number'not found'.
但是dbedit2是再另一个窗体中用于连接sells表的sell_number列的,和当前窗体没联系的
if (usertype<>'系统管理员') then
begin
messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
exit;
end;
unitdata.sells.Close;//与数据库中的销售记录表相连接,sells是ADOQuery的名称,也是销售记录表
unitdata.sells.SQL.Clear;
unitdata.sells.SQL.Add('select sum(product_price*sell_number) as total from sells where year(sell_time)=year(getdate())');//出错的地方
unitdata.sells.Open;
messagebox(handle,PChar('本年度销售额为 '+unitdata.sells.FieldByName('total').AsString+' 元。'),'年度盘点',MB_ICONinformation+mb_ok);
销售分析的代码,错误提示为:project superet.exe raised exception class edatabaseerror with message 'dbedit5:field'pro_stock'not found'.
但是dbedit5是再另一个窗体中用于连接products表的pro_stock列的,和当前窗体没联系的
var
i: integer;
begin
With Series1 do
Begin
unitdata.products.Close;
unitdata.products.SQL.Clear;
unitdata.products.SQL.Add('select distinct pro_name from products');
unitdata.products.Open; for i:=1 to unitdata.products.RecordCount do//出错的地方
begin
unitdata.sells.Close;
unitdata.sells.SQL.Clear;
unitdata.sells.SQL.Add('select sum(sell_number) as number from sells where product_name='+unitdata.products.FieldByName('pro_name').AsString);
unitdata.sells.Open;
Add(unitdata.sells.FieldByName('number').AsInteger,unitdata.products.FieldByName('pro_name').AsString,random(100000));
end;
end;
end;
我想这两个错误应该属于同一类型的,都是一样的报错,希望大家帮帮忙啊,万分感谢
unit sellanalyze;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, DbChart, Buttons;type
Tunitsellanalyze = class(TForm)
Chart1: TChart;
Series1: TPieSeries;
SpeedButton1: TSpeedButton;
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
unitsellanalyze: Tunitsellanalyze;implementationuses data;{$R *.dfm}procedure Tunitsellanalyze.FormShow(Sender: TObject);
var
i: integer;
begin
With Series1 do
Begin
unitdata.products.Close;
unitdata.products.SQL.Clear;
unitdata.products.SQL.Add('select distinct pro_name from products');
unitdata.products.Open; for i:=1 to unitdata.products.RecordCount do
begin
unitdata.sells.Close;
unitdata.sells.SQL.Clear;
unitdata.sells.SQL.Add('select sum(sell_number) as number from sells where product_name='+unitdata.products.FieldByName('pro_name').AsString);
unitdata.sells.Open;
Add(unitdata.sells.FieldByName('number').AsInteger,unitdata.products.FieldByName('pro_name').AsString,random(100000));
end;
end;
end;procedure Tunitsellanalyze.SpeedButton1Click(Sender: TObject);
begin
close;
end;end.
unitdata.products.Close;
unitdata.products.SQL.Clear;
unitdata.products.SQL.Add('select distinct pro_name from products');
unitdata.products.Open;
在这语句都没错,接下来就错了
procedure Tunitmain.N27Click(Sender: TObject);
begin
if (usertype<>'系统管理员') then
begin
messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
exit;
end;
unitdata.sells.Close;
unitdata.sells.SQL.Clear;
unitdata.sells.SQL.Add('select sum(product_price*sell_number) as total from sells where year(sell_time)=year(getdate()) and month(sell_time)=month(getdate()) and day(sell_time)=day(getdate())');//出错的地方,用断点查到的
unitdata.sells.Open;
messagebox(handle,PChar('今日销售额为 '+unitdata.sells.FieldByName('total').AsString+' 元。'),'今日盘点',MB_ICONinformation+mb_ok);
end;
http://www.anylib.com
from sells
where product_name='+unitdata.products.FieldByName('pro_name').AsString这句好像有问题,你看看sql语句有没有问题,郁闷阿