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

如何將 Table 存成 *.txt 檔.......

 
33403340
一般會員


發表:3
回覆:1
積分:0
註冊:2006-10-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-10-17 00:50:25 IP:220.132.xxx.xxx 未訂閱
請問高手大大們~~~
小弟我的問題...
是想將 table 存成 *.txt 格式
然後也可以將 *.txt 格式 讀取進 table 裡...
請問這該如何操作......(已爬文過..還蠻模糊的)
CoffeeX
中階會員


發表:18
回覆:121
積分:72
註冊:2005-02-18

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-12-08 09:42:24 IP:140.125.xxx.xxx 未訂閱

我的作法是先 new 一個 TSTringList,
將從table讀出之值一列一列存到StringList中,
最後 MyStringList->SaveToFile("tmp.txt");
------
=.=???
Coffee
版主


發表:31
回覆:878
積分:561
註冊:2006-11-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-12-08 11:15:35 IP:220.130.xxx.xxx 未訂閱
Help 應該很好用吧?

Loads a recordset from a file.

Delphi syntax:

procedure LoadFromFile(const FileName: WideString);

C syntax:

void __fastcall LoadFromFile(const WideString FileName);

Description

Call LoadFromFile to load the recordset for the calling ADO dataset component from a file. If the loading operation fails, the current recordset is neutralized (set to nil (Delphi) or NULL (C )), the dataset component remains inactive, and an EOleException exception is raised. If the attempt to load data from a file is successful, the ADO dataset component is automatically activated and the data made available.

FileName is a string containing the name of the file.

LoadFromFile closes the dataset component before loading the recordset from the file specified in FileName.

Saves a recordset to a file.

Delphi syntax:

procedure SaveToFile(const FileName: String = ''; Format: TPersistFormat = pfADTG);

C syntax:

void __fastcall SaveToFile(const WideString FileName = L"", TPersistFormat Format = pfADTG);

Description

Call SaveToFile to save the current recordset to a file. If the destination file already exists, it is overwritten.

FileName is a string containing the name of the destination file. This file remains open from the first call to SaveToFile until the dataset is closed. This file can be read by other applications while it is open, but they cannot write to the file.

Format specifies the file format for the saved recordset. By default, Format is pfADTG (Advanced Data TableGram format).

Note: Microsoft recommends using a client-side cursor (the dataset is opened with a CursorLocation property value of clUseClient). This way, if the provider used does not support saving the recordset the client cursor will provide the necessary functionality.
------
不論是否我發的文,在能力範圍皆很樂意為大家回答問題。
為了補我的能力不足之處,以及讓答案可以被重複的使用,希望大家能儘量以公開的方式問問題。
在引述到我的文時自然會儘量替各位想辦法,謝謝大家!
sdddds
一般會員


發表:10
回覆:9
積分:3
註冊:2003-05-17

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-12-08 13:50:43 IP:219.87.xxx.xxx 未訂閱
你也可以用TMemoryStream試試
TMemoryStream *IO_file=new TMemoryStream();
IO_file->WriteBuffer(Data,length);
IO_file->SaveToFile("temp.txt");
delete IO_file;
/*
定義IO_file並new一個TMemoryStream()
將資料寫入TMemoryStream的WriteBuffer並給他資料及長度
將IO_file內的資料存入temp.txt
最後在釋放你new出來的TMemoryStream
*/
系統時間:2024-11-23 17:55:12
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!