dm_datamodal.pas
来自「是一个用delphi设计的考勤系统」· PAS 代码 · 共 162 行
PAS
162 行
{
***************************************************************
* 说明:数据模板 *
***************************************************************
}
unit DM_DataModal;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB, oledb, comobj, ActiveX, DBTables;
type
TWindData = class(TDataModule)
AdoConn: TADOConnection;
PublicQuery: TADOQuery;
pZx_c304_csyscard: TADOStoredProc;
pzx_c306_gsjg: TADOStoredProc;
pzx_a203_yhzx: TADOStoredProc;
pZx_c305_iniyhk: TADOStoredProc;
pzx_c301_examcard: TADOStoredProc;
pzx_c307_khs: TADOStoredProc;
Lczerr: TADOTable;
LocalDb: TADOConnection;
pzx_c303_fixcard: TADOStoredProc;
LocalDbQuery: TADOQuery;
pzx_a205_getjsxx: TADOStoredProc;
pZx_d402_device: TADOStoredProc;
pzx_d403_cjxfjl: TADOStoredProc;
pzx_a207_xkxf: TADOStoredProc;
pzx_a204_xfjllz: TADOStoredProc;
pZx_c302_Cardkc: TADOStoredProc;
pZx_S_czydl: TADOStoredProc;
pUsr_101_UsrInfo: TADOStoredProc;
pUsr_102_GroupInfo: TADOStoredProc;
pcw_801_Bzxmxx: TADOStoredProc;
pcw_802_Bzxmcl: TADOStoredProc;
pCw_bz803_kkcl: TADOStoredProc;
pcx_901_jfjcx: TADOStoredProc;
pzx_a209_qcls: TADOStoredProc;
pZx_S_jgxx: TADOStoredProc;
pDJ_604_Afyxm: TADOStoredProc;
PDJ_601_Afymxdj: TADOStoredProc;
pDJ_609_Ajmhj: TADOStoredProc;
pDj_616_Jfls: TADOStoredProc;
pDJ_607_Myhcz: TADOStoredProc;
PDJ_610_Ayhtk: TADOStoredProc;
PDJ_608_Mjs: TADOStoredProc;
pDJ_613_Adjxs: TADOStoredProc;
pDJ_614_Adjjf: TADOStoredProc;
PDJ_615_Mdjjs: TADOStoredProc;
PDJ_605_Adjxm: TADOStoredProc;
pKq_N_Lbsz: TADOStoredProc;
pKq_N_Sjsz: TADOStoredProc;
pkq_A_Qjsz: TADOStoredProc;
Pkq_d_bcsd: TADOStoredProc;
pKq_A_Kqjl: TADOStoredProc;
pZx_S_yhxx: TADOStoredProc;
private
{ Private declarations }
function PromptDataSource(ParentHandle: THandle;
InitialString: WideString): WideString;
public
{ Public declarations }
function OpenDatabase(): boolean;
function OpenLocalDb(): boolean;
function ConfigConnstr(str: string): string;
end;
var
WindData: TWindData;
implementation
uses
UTSysCs, UGlobal;
{$R *.dfm}
function TWindData.OpenDatabase(): boolean;
var
strCon: string;
begin
result := False;
if gtsyscs.RemoteConnectString = '' then exit;
// strCon := LoadConnStr;
// if strCon='' then exit;
with ADOConn do
begin
if Connected then Connected := false;
ConnectionString := gtsyscs.RemoteConnectString;
try
Connected := true;
except
//连接数据库失败
on E: exception do
begin
exit;
end;
end;
result := true;
end;
end;
function TWindData.PromptDataSource(ParentHandle: THandle; InitialString: WideString): WideString;
var
DataInit: IDataInitialize;
DBPrompt: IDBPromptInitialize;
DataSource: IUnknown;
InitStr: PWideChar;
begin
Result := InitialString;
DataInit := CreateComObject(CLSID_DataLinks) as IDataInitialize;
if InitialString <> '' then
DataInit.GetDataSource(nil, CLSCTX_INPROC_SERVER,
PWideChar(InitialString), IUnknown, DataSource);
DBPrompt := CreateComObject(CLSID_DataLinks) as IDBPromptInitialize;
if Succeeded(DBPrompt.PromptDataSource(nil, ParentHandle,
DBPROMPTOPTIONS_PROPERTYSHEET, 0, nil, nil, IUnknown, DataSource)) then
begin
InitStr := nil;
DataInit.GetInitializationString(DataSource, True, InitStr);
Result := InitStr;
end;
end;
function TWindData.ConfigConnstr(str: string): string; //调用
var
sConnStr: string;
begin
sConnStr := PromptDataSource(Application.Handle, str);
ADOConn.Connected := False;
ADOConn.ConnectionString := sConnStr;
Result := sConnStr;
end;
function TWindData.OpenLocalDb: boolean;
begin
result := False;
with LocalDb do
begin
if Connected then Connected := false;
ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
'User ID=Admin;' +
'Data Source=' + GetCurrentDir + '\LoadDb.mdb;' +
'Mode=Share Deny None;' +
'Extended Properties="";' +
'Persist Security Info=False;';
try
Connected := true;
except
on E: exception do
begin
exit;
end;
end;
result := true;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?