同意楼上的,给你一段我写的代码,并不是针对性的解决你的问题,对你思考可能
有帮助,我懒得改了。
这段代码虽然是我写的,却是为了完成公司的项目,所以仅供参考,请不要直接用于
商业,毕竟我每个月才2000多也不容易。
//创建表
//muhx 20040417 am
function TDataManage.CreateDataTable: Boolean;
begin
Result := True;
if not DirectoryExists(fDataPath) then
begin
MkDir(fDataPath);
end;
with fTable do
begin
Active := False;
DatabaseName := fDataPath;
TableName := fTableName;
TableType := ttDBase;
if (Exists) then
begin
EmptyTable; //若表存在,清空表,避免在表中AppendData时发生重复
Exit;
end;
with FieldDefs do
begin
Clear;
Add('ZoneID', ftInteger, 0, False);
Add('BoardID', ftInteger, 0, False);
Add('CellName', ftString,30, False);
Add('IfSelected', ftBoolean, 0, False);
Add('Voltage', ftFloat, 0, False);
Add('TestTime', ftDateTime, 0, False);
end;
try
CreateTable;
except
on Exception do
begin
Result := False;
MessageDlg('不能在指定位置创建表!', mtError, [mbOK] ,0);
raise;
end;
end;
Active := False;
end;
end;