var
ap:tstringlist;
answer:integer;
begin
if (radiobutton1.Checked=false)and(radiobutton2.Checked=false) then
begin
showmessage('请选择表格类型');
radiobutton1.SetFocus;
exit;
end
else
if edit3.Text='' then
begin
showmessage('请输入数据库别名');
edit3.SetFocus;
exit;
end
else
if edit4.text='' then
begin
showmessage('请输入表格路径');
edit4.SetFocus;
exit;
end
else
begin
try
ap:=tstringlist.Create;
session.GetAliasNames(ap);
if (ap.IndexOf(edit3.text)=-1) then
begin
answer:=application.MessageBox((pchar('别名〖'+edit3.text+'〗不存在,现在创建吗?')),'BDE信息窗口',mb_okcancel);
if answer=idcancel then
begin
ap.Free;
exit;
end;
if radiobutton1.Checked=true then
begin
session.AddStandardAlias(edit3.text,edit4.Text,'paradox');
session.SaveConfigFile;//建数据库别名
end;
if radiobutton2.Checked=true then
begin
session.AddStandardAlias(edit3.text,edit4.Text,'DBase');
session.SaveConfigFile;
end;
end;
ap.Clear;
session.GetTableNames(edit3.text,'',false,false,ap);
if (ap.IndexOf(edit4.text)=-1) then
begin
answer:=application.MessageBox((pchar('别名中表格〖'+edit4.text+'〗不存在,现在创建吗?')),'表格信息窗口',mb_okcancel);
if answer=idcancel then
begin
ap.Free;
exit;
end;
with Table3 do
begin
active:=false;
databasename:=edit3.text;
tablename:=edit4.text;
if radiobutton1.Checked=true then
begin
tabletype:=ttparadox;//*.db的数据表
end;
if radiobutton2.Checked=true then
begin
tabletype:=ttDBase;//*.dbf的数据表
end;
with fielddefs do//加字段名
begin
clear;
add('sh',ftstring,30,false);
add('sm',ftstring,30,false);
end;
with indexdefs do
begin
clear;
add('shsy','sh',[ixprimary,ixunique]);//建索引
end;
createtable;
end;
Table3
end;
ap.Free;
except
end;