program StudentMIS;
uses
Forms,
SysUtils,
FormMain in 'FormMain.pas' {frmMain},
FormDepartment in 'FormDepartment.pas' {frmDepartment},
FormClass in 'FormClass.pas' {frmClass},
FormQuery in 'FormQuery.pas' {frmQuery},
FormPunish in 'FormPunish.pas' {frmPunish},
FormStudent in 'FormStudent.pas' {frmStudent},
FormReward in 'FormReward.pas' {frmReward},
FormChange in 'FormChange.pas' {frmChange};
{$R *.res}
function SQLConfigDataSource(
hwndParent: Integer;
fRequest: LongInt;
lpszDriverString: string;
lpszAttributes: string
): LongBool;
stdcall;
external 'ODBCCP32.DLL';
const
ODBC_ADD_DSN = 1;
ODBC_CONFIG_DSN = 2;
ODBC_REMOVE_DSN = 3;
ODBC_ADD_SYS_DSN = 4;
ODBC_CONFIG_SYS_DSN = 5;
ODBC_REMOVE_SYS_DSN = 6;
begin
Application.Initialize;
SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, // 添加系统数据源
'Microsoft Access Driver (*.mdb)', // 指定Access数据源
'DSN=StudentMIS;
DBQ=' // 数据源名称为 StudentMIS
+ ExtractFilePath(Application.ExeName) // 动态指定数据库文件路径
+ 'StudentMIS.MDB;
'
+ 'FIL=MS Access;
'
+ 'MaxBufferSize=512;
'
+ 'PageTimeout=5;
'
+ 'Description=学生信息管理'
);
Application.CreateForm(TfrmMain, frmMain);
Application.CreateForm(TfrmDepartment, frmDepartment);
Application.CreateForm(TfrmClass, frmClass);
Application.CreateForm(TfrmQuery, frmQuery);
Application.CreateForm(TfrmPunish, frmPunish);
Application.CreateForm(TfrmStudent, frmStudent);
Application.CreateForm(TfrmReward, frmReward);
Application.CreateForm(TfrmChange, frmChange);
Application.Run;
end.
动态配置ODBC