给你一段代码:
procedure TfrmProgramSet.CreateParamTable(Sender: TObject;tbName:String);
var
strAlias:TStringList;
iAnswer:Integer;
begin
if g_bCreateParamDirectory then
ParamPath:=ExtractFilePath(Application.ExeName)+'ParamData'
else
begin
ChDir(ExtractFilePath(Application.ExeName));
CreateDBDirectory(Sender);
ParamPath:=ExtractFilePath(Application.ExeName)+'ParamData';
end;
strAlias:=TStringList.Create;
Session.GetAliasNames(strAlias);
if (strAlias.IndexOf('HuaNan')=-1) then
begin
iAnswer:=Application.MessageBox('数据库不存在,现在创建吗?',
'信息窗口',MB_OKCANCEL);
if iAnswer = IDCANCEL then
begin
strAlias.Free;
Exit;
end;
Session.AddStandardAlias('HuaNan',ParamPath,'Paradox');
Session.SaveConfigFile;
end;
strAlias.Clear;
Session.GetTableNames('HuaNan','',False,False,strAlias);
if (strAlias.IndexOf(tbName)=-1 ) then
begin
iAnswer:=Application.MessageBox('参数表格不存在,现在创建一个?',
'信息窗口',MB_OKCANCEL);
if iAnswer = IDCANCEL then
begin
strAlias.Free;
Exit;
end;
tblParam.Active:=False;
tblParam.DatabaseName:='HuaNan';
tblParam.TableName:=tbName;
tblParam.TableType:=ttParadox;
tblParam.FieldDefs.Clear;
tblParam.FieldDefs.Add('通道',ftString,6,False); //通道号
tblParam.FieldDefs.Add('程序名称',ftString,10,False); //程序名称
tblParam.FieldDefs.Add('增益',ftInteger,0,False); //增益
tblParam.FieldDefs.Add('高通',ftString,10,False);
tblParam.FieldDefs.Add('低通',ftInteger,0,False);
tblParam.FieldDefs.Add('限幅',ftString,6,False);
tblParam.FieldDefs.Add('显示开关',ftString,4,False);
tblParam.FieldDefs.Add('颜色选取',ftString,4,False);
tblParam.IndexDefs.Clear;
tblParam.IndexDefs.Add('Index','通道',[ixPrimary,ixUnique]);
tblParam.CreateTable;
end;
end;