各位朋友帮帮忙。我程序在windows2000下一切正常。但到98下,系统退出时windows报非法操作。以下是我的代码:(200分)

  • 主题发起人 主题发起人 huhaojie
  • 开始时间 开始时间
H

huhaojie

Unregistered / Unconfirmed
GUEST, unregistred user!
程序同时支持sqlserver2000 ,access2000 (如果连接sqlserver2000在98下也不会出错)

项目文件
program Land_Mnc;

uses
Forms,
windows,
inifiles,
SysUtils,
MainFrm in 'MainFrm.pas' {MainForm},
SysDb in 'SysDb.pas' {SysDm: TDataModule},
userManagerFrm in 'userManagerFrm.pas' {userManagerForm},
SocketMd in 'SocketMd.pas' {socket_Md: TDataModule},
BusinessLogic in 'BusinessLogic.pas',
environmentSetFrm in 'environmentSetFrm.pas' {environmentSetForm},
GVar in 'GVar.pas',
NewEditUserFrm in 'NewEditUserFrm.pas' {NewEditUserForm},
PhoneDocFrm in 'PhoneDocFrm.pas' {PhoneDocForm},
PhoneSearchFrm in 'PhoneSearchFrm.pas' {PhoneSearchForm},
LoginFrm in 'LoginFrm.pas' {LoginForm},
inPutStrFrm in 'inPutStrFrm.pas' {inPutStrForm},
CodeFrm in 'CodeFrm.pas' {CodeForm},
statisticsFrm in 'statisticsFrm.pas' {statisticsForm},
ErrorInfoFrm in 'ErrorInfoFrm.pas' {ErrorInfoForm},
PhoneSetFrm in 'PhoneSetFrm.pas' {PhoneSetForm},
PhoneStateFrm in 'PhoneStateFrm.pas' {PhoneStateForm},
MoneyFrm in 'MoneyFrm.pas' {MoneyForm},
LogManagerFrm in 'LogManagerFrm.pas' {LogManagerForm},
listEditFrm in 'listEditFrm.pas' {listEditForm},
ReportViewFrm in 'ReportViewFrm.pas' {ReportViewForm},
CompanyInfoFrm in 'CompanyInfoFrm.pas' {CompanyInfoForm},
CoverFrm in 'CoverFrm.pas' {CoverForm},
adBarFrm in 'adBarFrm.pas' {adBarForm},
waitFrm in 'waitFrm.pas' {waitForm},
SelectPFrm in 'SelectPFrm.pas' {SelectPForm},
processTypeFrm in 'processTypeFrm.pas' {processForm},
phoneEditFrm in 'phoneEditFrm.pas' {phoneEditForm},
JustConFrm in 'JustConFrm.pas' {JustConForm};

{$R *.res}
var
sini:tinifile;
begin
Application.Initialize;
Application.Title := '无线公话网管系统';
try
CoverForm:=tCoverForm.create(application);
CoverForm.image1.onclick:=nil;
CoverForm.show;
CoverForm.Refresh ;
sleep(2000); //延迟2秒
finally
CoverForm.free;
end;
//后台数据库类型
try
sini:=TInifile.Create(ExtractFilePath(paramstr(0))+'Config_File.ini');
if sini.ReadString('DatabaseType','dbType','error')='access2000' then
begin
Gvar.db_type:=1;//access2000
end
else
begin
if sini.ReadString('DatabaseType','dbType','error')='sqlserver2000' then
begin
Gvar.db_type:=2;//ms sqlserver 2000
end
else
begin
Application.MessageBox(pchar('系统配置文件有误,系统终止运行!'),pchar('提示'),MB_OK+MB_ICONINFORMATION);
application.Terminate ;
end;
end;
finally
sini.free;
end;
//后台数据库类型
Application.CreateForm(TSysDm, SysDm);
Application.CreateForm(Tsocket_Md, socket_Md);
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.

数据连接模块
系统数据模块
}
unit SysDb;

interface

uses
SysUtils, Classes, DB, ADODB,inifiles,comobj,Forms,windows, AppEvnts;

type
TSysDm = class(TDataModule)
DbConnect: TADOConnection;
System_UserInfo: TADOTable;
System_UserInfosu_id: TStringField;
System_UserInfosu_name: TStringField;
System_UserInfosu_password: TStringField;
System_UserInfosu_popedom: TStringField;
System_UserInfosu_memo: TMemoField;
System_UserInfo_S: TDataSource;
dbError: TApplicationEvents;
procedure DbConnectBeforeConnect(Sender: TObject);
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
procedure dbErrorException(Sender: TObject; E: Exception);
private
{ Private declarations }
sConnect:string;//连接串
public
{ Public declarations }
end;

var
SysDm: TSysDm;


implementation

uses GVar;

{$R *.dfm}

procedure TSysDm.DbConnectBeforeConnect(Sender: TObject);
{读取ini文件,接连数据库
}
var encrypt_com:olevariant;//加密控件
password:string;//密码原文。
filename:string;//ini file name
confginifile:tinifile;//inifile
begin
filename:=ExtractFilePath(paramstr(0))+'Config_File.ini';
try
confginifile:=TInifile.Create(filename);
if Gvar.db_type=2 then
begin
//-database config-msSqlserver
encrypt_com:=createoleobject('encrypt_dll.ende');//建立对象
encrypt_com.decrypt(confginifile.ReadString('MsSqlServer','password','error'),password); //调入COM
sConnect:='Provider=SQLOLEDB.1;Password='+password+';Persist Security Info=True;User ID='
+confginifile.ReadString('MsSqlServer','username','error')+';Initial Catalog='
+confginifile.ReadString('MsSqlServer','databasename','error')+';Data Source='
+confginifile.ReadString('MsSqlServer','servername','error');
dbConnect.ConnectionString :=sConnect;
//-database config-msSqlserver
end else
begin//--Access 2000
encrypt_com:=createoleobject('encrypt_dll.ende');//建立对象
encrypt_com.decrypt(confginifile.ReadString('Access2000','password','error'),password); //调入COM
sConnect:='Provider=Microsoft.Jet.OLEDB.4.0;'+
'Data Source='+confginifile.ReadString('Access2000','databasename','error')+';'+
'Persist Security Info=True;'+
'Jet OLEDB:Database Password='+Password;//Jet OLEDB:Database

dbConnect.ConnectionString :=sConnect;
end;//--Access 2000
finally
confginifile.Free;
end;
end;

procedure TSysDm.DataModuleCreate(Sender: TObject);
begin
try
dbConnect.Connected :=true;//连接
blDbconnect:=true;
except
blDbconnect:=false;
Application.MessageBox(pchar('数据库连接失败!'),pchar('提示'),MB_OK+MB_ICONINFORMATION);
end;
end;

procedure TSysDm.DataModuleDestroy(Sender: TObject);
begin
dbConnect.Connected:=false;// disconnect
end;

procedure TSysDm.dbErrorException(Sender: TObject; E: Exception);
var sE:string;
begin
sE:=e.Message ;
Application.MessageBox(pchar(sE ),pchar('提示'),MB_OK+MB_ICONINFORMATION);
end;

end.
 
没人回答?
 
两台机器的ado版本是不是一致的。
 
我想不是,因为我在98机器上安装了mdac2.6 甚至2.7都试过。
后来我用odbc作测试没有这个错误。
我想可能是jet4.0的问题。等待高手。。。
 
在delphi环境中出错信息为:'raised too many consecutive' access violation at 0x34534.....
 
Gvar这个窗体/模块是在哪里创建的?我怎么没有发现它怎么创建的?
 
程序在98中运行时出不出错,还是只是退出时出错的。
其它的问题应该也没有。
你把adoexpress换成用ADO原生对象试试。
//关注此题,虽然我很菜。
 
运行时一切正常,是程序退出时出错。好像内存没释放。
在操作系统下出现“非法操作”。在delphi集成环境下“'raised too many consecutive' access violation at 0x34534.....
”。
gvar 是个单元,用于声明一些全局变量。
不行的话只能采用odbc了。。。
 
建议你重新New一个DataModule,把你现在的DataModule上的控件,代码都Copy过去,
用新的DM加入编译试试。
有点荒谬,不过我有时遇到过一些问题,实在找不到原因,重新New一个form代替原来的form居然好了。
 
procedure TSysDm.DataModuleDestroy(Sender: TObject);
begin
dbConnect.Connected:=false;// disconnect 去掉这一句试试
end;
 
后退
顶部