非也!!非也!! 我并不想重写DataBase DeskTop
但我使用DbiDoRestructure函数却只能删除最后一个字段,不知为何?
(程序如下:)
后来,我用SQL语句实现了删除任意一字段。但SQL不能实现Paradox数据库的一些
细节(如:增加缺省值等),并且我用SQL语句能做到增加字段,却不能插入字段。
按BDE HELP说 DbiDoRestructure能实现这些功能,她的例子程序也比较有用,但
我按她的例子做,却为何不能实现插入字段和删除任意一字段,请指教。。。
另外,有什么控件能实现这些功能,也可告诉我!!!
谢谢!!!
procedure TForm1.Button3Click(Sender: TObject);
var
TblDesc:CRTblDesc;
a_p,AddOp
CROpType;
i:integer;
pp,myFldDesc
FLDDesc;
Props:CURProps;
t_name
char;
hDB:hDBIDb;
begin
t_name:=allocmem(20);
strpcopy(t_name,Table1.TableName);
check(dbisetProp(hdbiobj(table1.Handle),curxltMODE,integer(xltNONE)));
check(DbiGetCursorProps(Table1.Handle, Props));
myFldDesc := Allocmem(Props.iFields * sizeof(FLDDesc));
check(DbiGetFieldDescs(table1.Handle, myFldDesc));
pp:=myFldDesc;
AddOp := allocmem(Props.iFields * sizeof(CROpType));
a_p:=Addop;
fillchar(Addop^,Props.iFields * sizeof(CROpType),crNOOP);
inc(Addop, Listbox1.ItemIndex);
Addop^:=crDROP;
addop:=a_p;
myFldDesc:=pp;
i:=1;
while(i<=props.iFields) do begin
if Addop^=crDROP then begin
myFldDesc^.iFldNum:=Props.iFields+1;
end
else
begin
myFldDesc^.iFldNum:=i;
end;
inc(i);
inc(myFldDesc);
inc(Addop);
end;
fillchar(TblDesc,sizeof(TblDesc),#0);
strcopy(TblDesc.szTblName, t_Name);
strcopy(TblDesc.szTblType, props.szTableType);
TblDesc.bPack:=TRUE;
TblDesc.iFldCount := Props.iFields-1 ;
TblDesc.pecrFldOp := A_p;
TblDesc.pfldDesc := pp;
check(dbigetobjfromobj(hdbiobj(table1.Handle),objdatabase,hdbiobj(hDb)));
table1.close;
DbiDoRestructure(hDb, 1, @TblDesc,nil, nil, nil, FALSE);
table1.open;
freemem(a_p,Props.iFields * sizeof(FLDDesc));
freemem(t_name,20);
freemem(pp,Props.iFields * sizeof(FLDDesc));
end