請問我要怎樣才可以獲得資料型態 |
尚未結案
|
adleycc
一般會員 ![]() ![]() 發表:2 回覆:5 積分:1 註冊:2005-03-18 發送簡訊給我 |
|
wst
初階會員 ![]() ![]() 發表:20 回覆:66 積分:37 註冊:2006-09-23 發送簡訊給我 |
轉貼其他前輩的作品
procedure TForm1.Button3Click(Sender: TObject);
var i: integer;
tmp: string;
begin
ClientDataSet1.open; //打開Table
ClientDataSet1.fieldDefs.update; //更新欄位資料
StringGrid1.RowCount := ClientDataSet1.FieldCount 1;
StringGrid1.ColCount := 5;
StringGrid1.Cells[1,0]:='欄位名稱';
StringGrid1.Cells[2,0]:='欄位型態';
StringGrid1.Cells[3,0]:='欄位大小';
StringGrid1.Cells[4,0]:='NOT NULL'; ClientDataSet1.IndexDefs.Update; //更新索引資料
StringGrid2.RowCount := ClientDataSet1.IndexDefs.count 1;
StringGrid2.ColCount := 4;
StringGrid2.Cells[1,0]:='索引名稱';
StringGrid2.Cells[2,0]:='索引欄位';
StringGrid2.Cells[3,0]:='索引型態';
begin
ClientDataSet1.fieldDefs.update; //更新欄位資料
for i := 0 to ClientDataSet1.fieldDefs.count - 1 do //Table的每一個欄位各跑一次
begin
with ClientDataSet1.fieldDefs.Items[i] do //取出欄位資訊
begin
StringGrid1.Cells[1, i 1] := Name; //取出欄位名稱
StringGrid1.Cells[2, i 1] := FieldtypeNames[datatype]; // 取出欄位型態
StringGrid1.Cells[3, i 1] := inttostr(size); //取出欄位大小
if Required then
StringGrid1.cells[4, i 1] := 'Y'; //是否Not Null
end;
end;
ClientDataSet1.IndexDefs.Update; //更索所引資料
for i := 0 to ClientDataSet1.IndexDefs.count - 1 do //每一個索引各跑一次
begin
with ClientDataSet1.IndexDefs.Items[i] do //取出索引資訊
begin
tmp := '';
if (ixPrimary in Options) then tmp := tmp 'P'; //Primary Key
if (ixUnique in Options) then tmp := tmp 'U'; //Uni-Key
if (ixDescending in Options) then tmp := tmp 'D'; //降冪 Key
if (ixExpression in Options) then tmp := tmp 'E'; //運算 Key
if (ixCaseInSensitive in Options) then tmp := tmp 'C'; // 分大小寫的KEY
StringGrid2.Cells[1, i 1] := Name; //取出索引名稱
StringGrid2.Cells[2, i 1] := fields; //取出索引的欄位資料
StringGrid2.Cells[3, i 1] := tmp; //取出索引的型態
end;
end;
end;
ClientDataSet1.close; // 關掉Table
end;
|
timhuang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |