以下代码在WIN
编译好的程序在WIN
//在之前uses ComObj
//声明连接字符串
Const
SConnectionString =
+
//=============================================================================
// Procedure: GetTempPathFileName
// Author : ysai
// Date :
// Arguments: (None)
// Result : string
//=============================================================================
function GetTempPathFileName():string;
//取得临时文件名
var
SPath
begin
GetTempPath(
GetTempFileName(SPath
result:=SFile;
DeleteFile(PChar(result));
end;
//=============================================================================
// Procedure: CreateAccessFile
// Author : ysai
// Date :
// Arguments: FileName:String;PassWord:string=
// Result : boolean
//=============================================================================
function CreateAccessFile(FileName:String;PassWord:string=
//建立Access文件
var
STempFileName:string;
vCatalog:OleVariant;
begin
STempFileName:=GetTempPathFileName;
try
vCatalog:=CreateOleObject(
vCatalog
result:=CopyFile(PChar(STempFileName)
DeleteFile(STempFileName);
except
result:=false;
end;
end;
//=============================================================================
// Procedure: CompactDatabase
// Author : ysai
// Date :
// Arguments: AFileName
// Result : boolean
//=============================================================================
function CompactDatabase(AFileName
//压缩与修复数据库
var
STempFileName:string;
vJE:OleVariant;
begin
STempFileName:=GetTempPathFileName;
try
vJE:=CreateOleObject(
vJE
format(SConnectionString
result:=CopyFile(PChar(STempFileName)
DeleteFile(STempFileName);
except
result:=false;
end;
end;
//=============================================================================
// Procedure: ChangeDatabasePassword
// Author : ysai
// Date :
// Arguments: AFileName
// Result : boolean
//=============================================================================
function ChangeDatabasePassword(AFileName
//修改ACCESS数据库密码
var
STempFileName:string;
vJE:OleVariant;
begin
STempFileName:=GetTempPathFileName;
try
vJE:=CreateOleObject(
vJE
format(SConnectionString
result:=CopyFile(PChar(STempFileName)
DeleteFile(STempFileName);
except
result:=false;
end;
end;
以下SQL语句在ACCESS XP的查询中测试通过
建表:
Create Table Tab
ID Counter
Name string
Age integer
[Date] DateTime);
技巧:
自增字段用 Counter 声明
字段名为关键字的字段用方括号[]括起来
建立索引:
下面的语句在Tab
Create Index iDate ON Tab
完成后ACCESS中字段Date索引属性显示为
下面的语句在Tab
Create Unique Index iName ON Tab
完成后ACCESS中字段
下一篇 教你玩转CSS3色彩