線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:762
推到 Plurk!
推到 Facebook!

請問我要怎樣才可以獲得資料型態

尚未結案
adleycc
一般會員


發表:2
回覆:5
積分:1
註冊:2005-03-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-09-02 16:27:39 IP:202.175.xxx.xxx 未訂閱
請問我要怎樣才可以獲得資料型態 例如: ..... with listbox1, adoquery1 do begin listbox1.items.add(fields[1].asstring ' ' fields[2].asstring .......); end; 用以上的方法資料欄一多就很煩,我想用一個for loop去做但我要怎樣才可以知道該field的型態呢(例如幾時是asstring, 或是asinteger);
wst
初階會員


發表:20
回覆:66
積分:37
註冊:2006-09-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-09-02 18:02:34 IP:211.76.xxx.xxx 未訂閱
轉貼其他前輩的作品 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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-09-05 10:53:10 IP:203.95.xxx.xxx 未訂閱
Hi, 看一下這篇討論, http://delphi.ktop.com.tw/topic.php?topic_id=30610 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=30630
系統時間:2024-06-24 19:59:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!