DATABASE NAME=c:\database.mdb //此文件肯定存在,而且目录正确
USER NAME=test
OPEN MODE=READ/WRITE
LANGDRIVER=
SYSTEM DATABASE=
PASSWORD=test
不知道这样配置是否正确。
name=backup
driver name=MSACCESS
错误如下:
General SQL error
-2147221164
Table
Alias:Backup
希望各位大侠赐教!
USER NAME=test
OPEN MODE=READ/WRITE
LANGDRIVER=
SYSTEM DATABASE=
PASSWORD=test
不知道这样配置是否正确。
name=backup
driver name=MSACCESS
错误如下:
General SQL error
-2147221164
Table
Alias:Backup
希望各位大侠赐教!
还有在sql Explore设置这个别名
斜杠不对吧, c:/database.mdb
但是我想知道,能不能够所有的设置都写在程序里面??
或者可以制作到安装程序中!!
program scglxt;uses
Forms,
Windows,
Messages,
Registry,
SysUtils,
Dialogs,
mainpas in 'mainpas.pas' {scglxtmainform},
startface in 'startface.pas' {Splashform},
login in 'login.pas' {loginform},
bmmlgl in 'bmmlgl.pas' {bmmlform},
ygdagl in 'ygdagl.pas' {frmygdagl},
sydwxx in 'sydwxx.pas' {sydwxxform},
ygbmdd in 'ygbmdd.pas' {frmygbmdd},
bmmlcx in 'bmmlcx.pas' {frmbmmlcx},
cpxxform in 'cpxxform.pas' {CpxxllForm},
CpxxEdit in 'CpxxEdit.pas' {CpxxAddEditForm},
cplbgl in 'cplbgl.pas' {frmcplbform},
PubProgFunc in 'PubProgFunc.pas' {PubProgFuncDataModule: TDataModule},
Xxcxpas in 'Xxcxpas.pas' {frmxxcxxz},
cpkhxmpas in 'cpkhxmpas.pas' {frmcpkhxm},
cpkhxmdy in 'cpkhxmdy.pas' {frmcpkhxmdy},
jsgspas in 'jsgspas.pas' {frmjsgs},
cpcrpas in 'cpcrpas.pas' {frmcpcrdjb},
cpgxszpas in 'cpgxszpas.pas' {frmcpgxsz},
cpxxcxpas in 'cpxxcxpas.pas' {frmcpxxcx},
cpgxxzcxpas in 'cpgxxzcxpas.pas' {frmcpgxxzcx},
ygzlxz in 'ygzlxz.pas' {frmygzlxz},
ygscdjbpas in 'ygscdjbpas.pas' {frmygscdjb},
cxtjxz in 'cxtjxz.pas' {frmcxtjxz},
gztjpas in 'gztjpas.pas' {frmgztjb},
taskjdt in 'taskjdt.pas' {frmtaskjdt},
scrbbpas in 'scrbbpas.pas' {frmscrbb},
mxcxpas in 'mxcxpas.pas' {frmmxcx},
xtcsszpas in 'xtcsszpas.pas' {frmxtcssz},
aboutpas in 'aboutpas.pas' {frmabout},
gxxxgl in 'gxxxgl.pas' {GxxxForm},
frmghczy in 'frmghczy.pas' {GhczyForm},
kcxxcxpas in 'kcxxcxpas.pas' {frmkcxxcx},
ghklpas in 'ghklpas.pas' {frmghkl},
ghxtsj in 'ghxtsj.pas' {frmghxtrq},
yhzczx in 'yhzczx.pas' {frmyhzczx},
yhgnqxsz in 'yhgnqxsz.pas' {frmyhgnsz},
kccspas in 'kccspas.pas' {frmkccs},
desktoppas in 'desktoppas.pas' {frmdesktop},
cpbsbypas in 'cpbsbypas.pas' {frmcpbsby};const
CM_RESTORE = WM_USER + $1000;
var
RvHandle: hWnd;
registerTemp: TRegistry;
DriverStr: string;
strFile, DBQFile: string;
TCSBCAODBC: Boolean;{$R *.res}begin
{If there's another instance already running, activate that one}
RvHandle := FindWindow('StoreSystemscglxt', nil);
if RvHandle > 0 then
begin
PostMessage(RvHandle, CM_RESTORE, 0, 0);
SetForegroundWindow(RvHandle);
Exit;
end;
strFile := Trim(AnsiLowerCase(ExtractFilePath(Application.ExeName) + 'scglbase.mdb'));
if not FileExists(strFile) then
begin
MessageDlg('数据库文件没有找到,系统无法运行', mtWarning, [mbOk], 0);
Exit;
end;
Application.Initialize;
Application.Title := '计件工资管理系统';
Splashform := TSplashform.Create(Application);
Splashform.show;
SplashForm.Update;
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey := HKEY_LOCAL_MACHINE; //设置根键值为HKEY_LOCAL_MACHINE
{检测系统是否注册}
TCSBCAODBC := False;
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources', False) then
if ValueExists('scglxt_ODBC') then
TCSBCAODBC := True
else
TCSBCAODBC := False;
CloseKey; {如果系统没有注册}
if TCSBCAODBC = False then
begin
{检测系统是否有Microsoft Access的ODBC驱动程序}
if openkey('Software\ODBC\ODBCINST.INI\ODBC Drivers', false) then
begin
if not ValueExists('Microsoft Access Driver (*.mdb)') then
begin
ShowMessage('系统中没有装入Microsoft Access Driver (*.mdb)的ODBC驱动程序,无法启动程序');
Closekey;
halt;
end;
CloseKey;
end
else
begin
ShowMessage('系统注册表存在问题,无法启动程序');
CloseKey;
halt;
end; {读取Microsoft Access Driver (*.mdb)的驱动程序的存放位置}
if Openkey('Software\ODBC\ODBCINST.INI\Microsoft Access Driver (*.mdb)', false) then
DriverStr := ReadString('Driver')
else
begin
ShowMessage('读取系统中Microsoft Access Driver (*.mdb)的ODBC驱动程序有误,导致无法加载启动程序');
Closekey;
halt;
end;
CloseKey; {检测系统是否创建fwxxgl_ODBC}
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources', False) then
if ValueExists('scglxt_ODBC') then
TCSBCAODBC := True
else
TCSBCAODBC := False;
CloseKey;
{创建fwxxgl_ODBC} if not TCSBCAODBC then
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources', True) then
begin
WriteString('scglxt_ODBC', 'Microsoft Access Driver (*.mdb)');
CloseKey;
end
else
begin
ShowMessage('写入系统注册表数据错误,无法加载启动程序');
Closekey;
halt;
end; if not TCSBCAODBC then
begin
if OpenKey('Software\ODBC\ODBC.INI\scglxt_ODBC', True) then
begin
WriteString('DBQ', strFile); //指定数据库
WriteString('Description', '生产管理系统的数据源'); //数据源描述
//驱动程序DLL文件,根据系统安装的目录不同而不同。
WriteString('Driver', DriverStr); //驱动程序
WriteInteger('DriverId', 25);
WriteInteger('Exclusive', 0);
WriteInteger('SafeTransactions', 0);
WriteString('UID', '');
//CreateKey('Engines');
OpenKey('Engines', True);
//CreateKey('Jet');
if OpenKey('Jet', True) then
begin
WriteString('ImplicitCommitSync', '');
WriteInteger('MaxBufferSize', 2048);
WriteInteger('PageTimeout', 5);
WriteInteger('Threads', 3);
WriteString('UserCommitSync', 'Yes');
end
else
begin
ShowMessage('写入系统注册表数据错误,无法加载启动程序');
Closekey;
halt;
end;
TCSBCAODBC := True;
CloseKey;
end
else
begin
ShowMessage('写入系统注册表数据错误,无法加载启动程序');
Closekey;
halt;
end;
end;
{向系统注册表写入系统注册信息}
if OpenKey('Software\scglxt', True) then
begin
WriteString('Register', 'True');
CloseKey;
end
else
begin
ShowMessage('写入系统注册表数据错误,无法加载启动程序');
Closekey;
halt;
end;
end
else
begin
if OpenKey('Software\ODBC\ODBC.INI\scglxt_ODBC', False) then
begin
if ValueExists('DBQ') then
begin
DBQFile := AnsiLowerCase(Trim(ReadString('DBQ')));
if strFile <> DBQFile then
begin
DeleteValue('DBQ');
WriteString('DBQ', strFile); //指定数据库
end
end;
end
else
begin
ShowMessage('系统注册表存在问题,无法启动程序');
CloseKey;
halt;
end;
CloseKey;
end;
end;
registerTemp.Free;
Application.CreateForm(Tscglxtmainform, scglxtmainform);
Application.Run;
end.