paradox修改表结构困了我N久,高分请有经验的帮解决下. ( 积分: 200 )

  • 主题发起人 主题发起人 13380073758
  • 开始时间 开始时间
1

13380073758

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure fDbiDoRestructure(Tbl: TTable; Field: TField; MinVal, MaxVal,
DefVal: pLongint; Required: Bool);
var
hDb: hDbiDb;
TblDesc: CRTblDesc;
VChk: pVChkDesc;
Dir: String;
NumVChks: Word;
OpType: CROpType;

begin
NumVChks := 0;
SetLength(Dir, dbiMaxNameLen + 1);
Check(DbiGetDirectory(Tbl.DBHandle, False, PChar(Dir)));
SetLength(Dir, StrLen(PChar(Dir)));
VChk := AllocMem(sizeof(VChkDesc));
try
FillChar(TblDesc, sizeof(CRTblDesc), #0);

VChk.iFldNum := Field.Index + 1;
Tbl.DisableControls;
Tbl.Close;
Check(DbiOpenDatabase(nil, nil, dbiReadWrite, dbiOpenExcl,
nil, 0, nil, nil, hDb));
Check(DbiSetDirectory(hDb, PChar(Dir)));
with VChk^ do
begin
bRequired := Required;
if MinVal <> nil then
begin
Inc(NumVChks);
bHasMinVal := True;
move(MinVal^, aMinVal, sizeof(MinVal^));
end
else
bHasMinVal := False;
if MaxVal <> nil then

begin
Inc(NumVChks);
bHasMaxVal := True;
move(MaxVal^, aMaxVal, sizeof(MaxVal^));
end
else
bHasMaxVal := False;
if DefVal <> nil then
begin
Inc(NumVChks);
bHasDefVal := True;
move(DefVal^, aDefVal, sizeof(DefVal^));
end
else
bHasDefVal := False;

end;
TblDesc.iValChkCount := NumVChks;
TblDesc.pVChkDesc := VChk;
OpType := crADD;
TblDesc.pecrValChkOp := @OpType;

StrPCopy(TblDesc.szTblName, Tbl.TableName);
StrCopy(TblDesc.szTblType, szParadox);
Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
finally
Check(DbiCloseDatabase(hDb));
FreeMem(VChk, sizeof(VChkDesc));
Tbl.EnableControls;
Tbl.Open;
end;
end;
上面的代码是从delphi 官方网站下拷下来的,但当我
DbiDoRestructure(Table4, Table4.Fields[0], nil, nil, nil, True)
调用时,Required属性总是更改不了,不知道为什么
 
后退
顶部