我如果不用动态建立数据模块.我只动态建立adoquery,adoconnection,错误依旧,错误的提示依旧.
现在把我的完整代码显示如下,我今天处理了一天都没解决.
program Project1;
uses
windows,
Forms,
dialogs,
SysUtils,
Unit1 in 'Unit1.pas' {mainForm},
Unit2 in 'Unit2.pas' {JingGao},
Unit3 in 'Unit3.pas' {guanyu},
Unit4 in 'Unit4.pas' {denglu},
Unit5 in 'Unit5.pas' {XinShuRuKu},
Unit6 in 'Unit6.pas' {TuShuGuanLi},
Unit7 in 'Unit7.pas' {DuZheGuanLi},
Unit8 in 'Unit8.pas' {JieHuanGuanLi},
Unit9 in 'Unit9.pas' {QuanXianGuanLi},
Unit10 in 'Unit10.pas' {YiJieTuShu},
Unit11 in 'Unit11.pas' {XinXiChaXun},
Unit12 in 'Unit12.pas' {TuShuChaXun},
Unit13 in 'Unit13.pas' {DuZheChaXun},
Unit14 in 'Unit14.pas' {JieYueChaXun},
Unit15 in 'Unit15.pas' {RiZhiGuanLi},
Unit16 in 'Unit16.pas' {XuanXiangSheZhi},
Unit17 in 'Unit17.pas' {BeiFenHuanYuan},
Unit18 in 'Unit18.pas' {FuFeiZhuCe},
Unit19 in 'Unit19.pas' {muluxuanze},
Unit20 in 'Unit20.pas' {huanyuanxuanze},
Unit21 in 'Unit21.pas' {DataModuleado: TDataModule};
{$R *.res}
var
mymutex:Thandle;
jinggao:Tjinggao;
denglu:Tdenglu;
begin
denglu:=Tdenglu.create(nil);//动态创建实例 - >进而触发CREATE事件
denglu.ShowModal;
//showmessage('ok'); //测试用
Jinggao:=nil;
mymutex:=createmutex(nil,false,'mymutex');
If waitforsingleobject(mymutex,0)<>wait_timeout then //只能运行一个实例
begin
Application.Initialize;
Application.Title := '图书管理系统V1.0';
Application.CreateForm(TmainForm, mainForm);
Application.CreateForm(TDataModuleado, DataModuleado);
Application.CreateForm(Tguanyu, guanyu);
Application.CreateForm(TXinShuRuKu, XinShuRuKu);
Application.CreateForm(TTuShuGuanLi, TuShuGuanLi);
Application.CreateForm(TDuZheGuanLi, DuZheGuanLi);
Application.CreateForm(TJieHuanGuanLi, JieHuanGuanLi);
Application.CreateForm(TQuanXianGuanLi, QuanXianGuanLi);
Application.CreateForm(TYiJieTuShu, YiJieTuShu);
Application.CreateForm(TXinXiChaXun, XinXiChaXun);
Application.CreateForm(TTuShuChaXun, TuShuChaXun);
Application.CreateForm(TDuZheChaXun, DuZheChaXun);
Application.CreateForm(TJieYueChaXun, JieYueChaXun);
Application.CreateForm(TRiZhiGuanLi, RiZhiGuanLi);
Application.CreateForm(TXuanXiangSheZhi, XuanXiangSheZhi);
Application.CreateForm(TBeiFenHuanYuan, BeiFenHuanYuan);
Application.CreateForm(TFuFeiZhuCe, FuFeiZhuCe);
Application.CreateForm(Tmuluxuanze, muluxuanze);
Application.CreateForm(Thuanyuanxuanze, huanyuanxuanze);
Application.Run;
end
else
begin
try
jinggao:=Tjinggao.create(application);
jinggao.Showmodal;
finally
jinggao.Free;
//application.MessageBox('图书管理系统已经运行!!!!','警告!'mb_ok,);
end;
application.Terminate;
end;
end.
---------------------------------------------------------------------------------------
http://www.efile.com.cn/efile/hygsxysxyhyg/%BD%D8%CD%BC.JPG
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, TFlatSpeedButtonUnit,shellapi,
TFlatButtonUnit, TFlatEditUnit, TFlatComboBoxUnit;
type
Tdenglu = class(TForm)
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
Label3: TLabel;
Label4: TLabel;
Bevel2: TBevel;
denglu: TFlatSpeedButton;
FlatSpeedButton2: TFlatSpeedButton;
xiexin: TFlatSpeedButton;
yonghuming: TFlatComboBox;
kouling: TFlatEdit;
procedure FlatSpeedButton4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FlatSpeedButton2Click(Sender: TObject);
procedure dengluClick(Sender: TObject);
procedure xiexinClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
denglu: Tdenglu;
implementation
uses Unit18, Unit21,adodb;
{$R *.dfm}
procedure Tdenglu.FlatSpeedButton4Click(Sender: TObject);
begin
denglu.Show;
end;
procedure Tdenglu.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//application.Terminate;
end;
procedure Tdenglu.FlatSpeedButton2Click(Sender: TObject);
begin
//application.Terminate;
end;
procedure Tdenglu.dengluClick(Sender: TObject);
begin
;//从权限表判断用户名和密码是否正确
end;
procedure Tdenglu.xiexinClick(Sender: TObject);
begin
shellexecute(handle,'open','mailto:hygks@163.com',nil,nil,sw_show);
end;
procedure Tdenglu.FormCreate(Sender: TObject);
var
i:integer;
adoquery1:Tadoquery;
adoconnection1:Tadoconnection;
begin
try
label1.Caption:=formatDateTime('yyyy"年"m"月"d"日"', Now)
+'('+formatdatetime('aaaa',date)+')';
//动态创建adoconnection,adoquery
adoconnection1:=Tadoconnection.create(nil);
adoconnection1.ConnectionString:=
'provider=microsoft.jet.oledb.4.0;data source='
+extractfilepath(paramstr(0))+'tushudatabase.mdb;'+'jet oledb:database password='
+';persist secutity info=false';
adoquery1:=Tadoquery.create(nil);
adoquery1.connection:=adoconnection1;
with adoquery1 do
begin
sql.clear;
sql.add('select 登陆用户名 from 权限密码表' );
open;
first;
for i:=0 to recordcount-1 do
begin
yonghuming.Items.Add(fieldbyname('登陆用户名').asstring);
next;
end;
close;
end;
finally
;
end;
end;
end.