全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2130
推到 Plurk!
推到 Facebook!

adotable讀取access順序錯誤

答題得分者是:st33chen
aconxu
一般會員


發表:18
回覆:41
積分:11
註冊:2006-12-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-04-01 16:49:19 IP:60.250.xxx.xxx 訂閱
Dear all ,

我想要利用adotable將access中的資料讀出來~
並且將資料放入StringList中~
但是~不知道為什麼~有些資料順序會錯誤

ex.
access中的資料

id Data
---------------------
0 A
1 B
2 C
3 D
4 E
5 F
6 G
7 H
8 I
9 J


StringList->Clear(); //先清空StringList
ADOTable->Open();
ADOTable->First();

while(!ADOTable->Eof)
{
MsgList->Add(ADOTable->FieldByName(FieldName)->AsString);
ADOTable->Next();
}
ADOTable->Close();


執行完後發現~StringList->Text中~ A->B->C->D->E->F->G-J->I->H
在捉取access時~為什麼會出錯導至StringList中的資料順序也出錯

謝謝
aconxu
一般會員


發表:18
回覆:41
積分:11
註冊:2006-12-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-04-01 16:54:27 IP:60.250.xxx.xxx 訂閱
Dear all ,

剛剛看到一個可以解決問題的方法
就是新增~
ADOTable->Sort="Id";

這樣是可以解決問題~
但是~我還是不懂為什麼會出錯~

如果有人可以回答我~
麻煩幫個忙~

謝謝
AndrewK
高階會員


發表:6
回覆:151
積分:161
註冊:2006-10-09

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-04-01 22:15:27 IP:60.250.xxx.xxx 訂閱
1.在捉取access時~為什麼會出錯導至StringList中的資料順序也出錯
這句很難明白你的意思,是出什麼錯導至 stringlist 中的資料順序也出錯

2.如果想了解為何抓取 access 時,存至 stringlist 的順序會有問題
你可以直接打開 access 看看資料的順序,你就明白了


------
Just Do It
-------------------------
其實男生不是真的喜歡你不減肥,而是喜歡你愛吃還不肥;也不是真的喜歡你不化妝,而是喜歡你素顏也好看;也不是真的喜歡你瘦,而是喜歡你瘦卻有胸;也不是真喜歡你獨立,而是他忙的時候別煩他。女孩子,太認真你就輸了。
aconxu
一般會員


發表:18
回覆:41
積分:11
註冊:2006-12-19

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-04-02 08:32:47 IP:60.250.xxx.xxx 訂閱
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><meta content="Word.Document" name="ProgId" /><meta content="Microsoft Word 11" name="Generator" /><meta content="Microsoft Word 11" name="Originator" /><link href="file:///C:\DOCUME~1\ZITO~1.CHE\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml> Normal 0 0 2 false false false MicrosoftInternetExplorer4 </xml><![endif]--><!--[if gte mso 9]><xml> </xml><![endif]--><style type="text/css"> <!-- /* Font Definitions */ @font-face {font-family:新細明體; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:PMingLiU; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} @font-face {font-family:"\@新細明體"; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:新細明體; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:表格內文; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <meta content="Microsoft Word 11" name="Generator" /><meta content="Microsoft Word 11" name="Originator" /><link href="file:///C:\DOCUME~1\ZITO~1.CHE\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml> Normal 0 0 2 false false false MicrosoftInternetExplorer4 </xml><![endif]--><!--[if gte mso 9]><xml> </xml><![endif]--><style type="text/css"> <!-- /* Font Definitions */ @font-face {font-family:新細明體; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:PMingLiU; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} @font-face {font-family:"\@新細明體"; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:新細明體; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:表格內文; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> </xml><![endif]--><style type="text/css"> <!-- /* Font Definitions */ @font-face {font-family:新細明體; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:PMingLiU; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} @font-face {font-family:"\@新細明體"; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:新細明體; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:表格內文; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> 如果想了解為何抓取時,存至的順序會有問題你可以直接打開看看資料的順序,你就明白了

access裡的資料我開啟後~資料的順序是正確的~
所以我才不能理解~為什麼捉出來的順序會錯

謝謝



st33chen
尊榮會員


發表:15
回覆:591
積分:1201
註冊:2005-09-30

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-04-02 17:51:21 IP:122.116.xxx.xxx 未訂閱
您好,

我的想法是,
db 的可貴就在於 亂序儲存的資料可以用想要的順序讀出來.
不然直接用本文檔就好了啊
關鍵就在 keyfield

帶 key 的 query 就是依 key 的順序讀出(logical), 不帶 key 的 query 就是依儲存順序讀出(physical)
所以您加了 key 就依您想要的順序讀出來

至於 打開 mdb 看資料時其順序是對的, 應該是該工具內定使用 key .
而 adoquery 或 adotable 內定不使用 key 吧.

或許您用別的工具開 mdb 看看可以看到不同的結果


胡說一番, 參考一下.
------
IS IT WHAT IT IS
我是 李慕白 請倒著唸.
又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦);
都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲.
編輯記錄
st33chen 重新編輯於 2009-04-02 17:52:52, 註解 無‧
st33chen 重新編輯於 2009-04-02 17:55:00, 註解 無‧
系統時間:2024-04-24 10:40:08
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!