Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save to a text file

Status
Not open for further replies.

nazbad

Technical User
Apr 3, 2001
3
MY
Hi,

I'm new at C++ Builder,

How do I save a records set return by ADO Query to a text file?

Thanks
 
I think there isn't a direct way to do that.

What you have to do is to write your own function and copy each record into a text file.

Something like this:

Code:
TStringList *MyTextFile = new TStringList ();
MyQuery->First();
for (int i=0; i<MyQuery->RecordCount; i++)
{
   /*You have to add the string conaining all the record, you can use delimitiers as ',' or tab characters, ro whatever you want*/

   MyTextFile->Append (YourPreparedString);  
   MyQuery->Next();
}
MyTextFile->SaveToFile ("AnyPath");
delete MyTextFile;
Your prepared string might be something like this:

Code:
AnsiString YourPreparedString;
YourPreparedString = MyQuery_Field1 + ", " + MyQuery_Field2 + ... etc;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top