如何用ADOX创建一个“自动编号”字段?接受答案后马上给分。 (160分)

H

HLHGOD

Unregistered / Unconfirmed
GUEST, unregistred user!
如何用ADOX创建一个“自动编号”字段?
 
ALter .....
 
请参见 http://www.delphibbs.com/delphibbs/dispq.asp?lid=1296311

在delphi中Import type library,生成Adox_tlb.pas,引用它

procedure TForm1.Button1Click(Sender: TObject);
var cat:_Catalog;
tb1:_Table;
col1:_Column;
i:integer;
begin
cat:=coCatalog.Create;
cat.Set_ActiveConnection(self.ADOConnection1.ConnectionObject);
tb1:=coTable.create;
tb1.Name:='test';
cat.Tables.Append(tb1);
col1:=coColumn.Create;
col1.ParentCatalog:=cat;
col1.Name:='t2';
col1.Type_:= adinteger;

for i:=0 to col1.Properties.Count-1 do
begin
if Lowercase(col1.Properties.Item.Name) = 'autoincrement' then
col1.Properties.Item.Value:=true;
end;
tb1.Columns.Append(col1,col1.type_,col1.definedsize);


end;
 
类型为autoincrement就行。
 
sql server 中
用A LTER TABLE 表 ADD 列名 [int] identity(1,1) not null

 
谢谢各位,等我验证后就发分
 
用ALTER TABLE 表 ADD 列名 int identity(1,1) not null
 
顶部