有关Access数据库中主从表记录问题,进来看看! (100分)

  • 主题发起人 主题发起人 tony.xu
  • 开始时间 开始时间
T

tony.xu

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个人事管理程序,数据库使用Access,现在我有两个问题请教

1。现在数据库已经100多兆了,程序运行起来很慢(在程序启动时),
 现在总共记录大概1000条左右,是不是因为我将图片保存于数据库的原因?(图片为2寸扫描件)

2。现在有“教师表”(有图片字段)和“资格证表”,它们是主从表的关系,为何当我浏览主表记录到128条
 时从表记录就都不显示了(指在DBGrid中),(但是数据库中是有数据的),128条记录之前一切正常,这是Access的问题吗?如何解决?急急急
 
1、建议在存图片是把图片格式转为JPG,或压缩一下,用的时候再解压

2、在游览记录时不要打开所有记录,可每次打开几十条(select to 50 * talle)
 
压缩图片
 
我图片保存时的格式为jpg,再压缩,压缩不了多少了吧
 
把代码贴出来看看
 
unit Teachermainfrm;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBCtrls, Grids, DBGrids, ExtCtrls, ComCtrls, ToolWin, XPMenu,
Menus, XP_Button, DB, FR_DSet, FR_DBSet, FR_Class,shellapi;

type
TTeachermain = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
add: TMenuItem;
edit: TMenuItem;
del: TMenuItem;
N8: TMenuItem;
save: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
N23: TMenuItem;
CoolBar1: TCoolBar;
Panel1: TPanel;
Panel2: TPanel;
R1: TMenuItem;
N24: TMenuItem;
Panel3: TPanel;
Panel4: TPanel;
ToolBar1: TToolBar;
addbtn: TXP_Button;
editbtn: TXP_Button;
delbtn: TXP_Button;
querybtn: TXP_Button;
reportbtn: TXP_Button;
exitbtn: TXP_Button;
Toppanel: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Panel8: TPanel;
Panel9: TPanel;
DBGrid1: TDBGrid;
Toppanel1: TPanel;
Panel11: TPanel;
Panel12: TPanel;
Panel13: TPanel;
Panel14: TPanel;
DBGrid2: TDBGrid;
Panel15: TPanel;
Panel16: TPanel;
Panel17: TPanel;
DBImage1: TDBImage;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
DataSource1: TDataSource;
DataSource2: TDataSource;
frReport1: TfrReport;
frDBDataSet1: TfrDBDataSet;
frDBDataSet2: TfrDBDataSet;
frReport2: TfrReport;
XPMenu: TXPMenu;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DataSource1StateChange(Sender: TObject);
procedure addbtnClick(Sender: TObject);
procedure editbtnClick(Sender: TObject);
procedure delbtnClick(Sender: TObject);
procedure exitbtnClick(Sender: TObject);
procedure reportbtnClick(Sender: TObject);
procedure querybtnClick(Sender: TObject);
procedure addClick(Sender: TObject);
procedure editClick(Sender: TObject);
procedure delClick(Sender: TObject);
procedure saveClick(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N23Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure DBGrid2DblClick(Sender: TObject);
procedure N24Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure DataSource1DataChange(Sender: TObject; Field: TField);
procedure DataSource2DataChange(Sender: TObject; Field: TField);
procedure SortbyIDClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Teachermain: TTeachermain;

implementation

uses DataModule, addteacherinfofrm, AddZhigezheng, QueryTeacher;

{$R *.dfm}

procedure TTeachermain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=Cafree;
end;

procedure TTeachermain.DataSource1StateChange(Sender: TObject);
begin
if Datasource1.State in [dsinsert,dsedit] then
begin
addbtn.Enabled:=false;
add.Enabled:=false;
editbtn.Enabled:=false;
edit.Enabled:=false;
delbtn.Enabled:=false;
del.Enabled:=false;
querybtn.Enabled:=false;
reportbtn.Enabled:=false;
exitbtn.Enabled:=false;
end
else
begin
addbtn.Enabled:=True;
add.Enabled:=true;
editbtn.Enabled:=True;
edit.Enabled:=true;
delbtn.Enabled:=True;
del.Enabled:=true;
querybtn.Enabled:=True;
reportbtn.Enabled:=True;
exitbtn.Enabled:=True;
end;
end;

procedure TTeachermain.addbtnClick(Sender: TObject);
begin
Application.CreateForm(TAddteacher,addteacher);
addteacher.show;
Datamodule1.Teachers.Append;
end;

procedure TTeachermain.editbtnClick(Sender: TObject);
begin
Application.CreateForm(TAddteacher,addteacher);
addteacher.show;
Datamodule1.Teachers.edit;
end;

procedure TTeachermain.delbtnClick(Sender: TObject);
begin
if messageDlg('ȷʵҪɾ³ýÂð£¿',mtwarning,[mbyes,mbno],0)=mryes then
begin
datamodule1.Teachers.Delete;
end;

end;

procedure TTeachermain.exitbtnClick(Sender: TObject);
begin
if MessageDlg('ȷʵҪÍ˳ö½Ìʦµµ°¸¹ÜÀíÂð£¿',mtinformation,[mbyes,mbno],0)=mryes then
Close;
end;

procedure TTeachermain.reportbtnClick(Sender: TObject);
begin
if dbgrid2.DataSource.DataSet.RecordCount<>0 then
begin
frreport1.ShowReport;
end
else
begin
frreport2.ShowReport;
end;
end;

procedure TTeachermain.querybtnClick(Sender: TObject);
begin
Application.CreateForm(Tqueryteacherfrm,queryteacherfrm);
queryteacherfrm.show;
end;

procedure TTeachermain.addClick(Sender: TObject);
begin
addbtn.Click;
end;

procedure TTeachermain.editClick(Sender: TObject);
begin
editbtn.Click;
end;

procedure TTeachermain.delClick(Sender: TObject);
begin
delbtn.Click;
end;

procedure TTeachermain.saveClick(Sender: TObject);
begin
Datamodule1.Teachers.Post;
Datamodule1.zigezheng.Post;
end;

procedure TTeachermain.N13Click(Sender: TObject);
begin
Datamodule1.Teachers.Sort:='id';
end;

procedure TTeachermain.N23Click(Sender: TObject);
begin
Datamodule1.Teachers.Refresh;
Datamodule1.zigezheng.Refresh;
Toppanel.Caption:='ÖйúÎè½Ìʦ¹²ÓÐ: '+IntToStr(Datamodule1.Teachers.RecordCount)+' ÈË';
end;

procedure TTeachermain.N3Click(Sender: TObject);
begin
Exitbtn.Click;
end;

procedure TTeachermain.DBGrid1DblClick(Sender: TObject);
begin
if Teachermain.DBGrid1.DataSource.DataSet.RecordCount =0 then
begin
showmessage('µ±Ç°±í¸ñûÓÐÊý¾Ý,ÎÞ·¨ÏÔʾ£¡');
end
else
begin
Application.CreateForm(TAddteacher,addteacher);
addteacher.show;
end;
end;

procedure TTeachermain.DBGrid2DblClick(Sender: TObject);
begin
if Teachermain.DBGrid2.DataSource.DataSet.RecordCount =0 then
begin
showmessage('µ±Ç°±í¸ñûÓÐÊý¾Ý,ÎÞ·¨ÏÔʾ£¡');
end
else
begin
Application.CreateForm(Taddzhigezhengfrm,addzhigezhengfrm);
addzhigezhengfrm.showmodal;
end;
end;

procedure TTeachermain.N24Click(Sender: TObject);
begin
reportbtn.Click;
end;

procedure TTeachermain.N21Click(Sender: TObject);
begin
if shellExecute(handle,'open','help.pdf',nil,nil,SW_show) <32 then
Application.MessageBox('´ò¿ª°ïÖúÎļþ³ö´í,Çë¼ì²éÄãÊÇ·ñ×°ÓÐAcrobat Reader¼°°ïÖúÎļþÊÇ·ñ¿ÉÓã¡','Ìáʾ',mb_ok);
end;

procedure TTeachermain.DataSource1DataChange(Sender: TObject;
Field: TField);
begin
Toppanel.Caption:='ÖйúÎè½Ìʦ×ÜÊý: '+IntToStr(Datamodule1.Teachers.RecordCount)+' ÈË';
end;

procedure TTeachermain.DataSource2DataChange(Sender: TObject;
Field: TField);
begin
Toppanel1.Caption:='µ±Ç°ÖйúÎè½ÌʦÓУº '+IntToStr(datasource2.DataSet.RecordCount)+' ÕÅ×ʸñÖ¤';
end;

procedure TTeachermain.SortbyIDClick(Sender: TObject);
begin
Datamodule1.Teachers.Sort := 'Bianhao ASC';
end;

end.
 
多人接受答案了。
 
后退
顶部