Click to See Complete Forum and Search --> : Save records from DBGrid to Txt File


Leite33
October 18th, 2006, 01:43 AM
Hi
I have an application that is connected with SQLServer 2000 and BCB6.
I have the records in DBGrid to saw them in my application.. My question is how i can save this records to txt file?? Any code ideas??
My fields are: Name and Size

So i want to save them in txt file.. Is possible that???
i did something like this
ADOTable1->SaveToFile("c:\\86.txt"); but is totally wrong because i want to save only the above 2 fields and all i get in this file is strange letters
Please help

Alventis
October 18th, 2006, 09:58 AM
Try "manually" looping on the records and writing the relevant values to the file the way you want. There probably isn't a one-line solution to this...

Leite33
October 19th, 2006, 01:27 AM
what you mean? Any code ideas???

Alventis
October 23rd, 2006, 09:23 AM
Following is what I meant expressed in semi-pseudo-code:

for (int i = 0; i < ADOTable1->RecordCount; i++)
{
Write to file the values you want, e.g.:
ADOTable1->FieldByName("Abc")->AsString + ", " + ADOTable1->FieldByName("Xyz")->AsString + ...
}

Leite33
October 24th, 2006, 12:24 AM
Ok seem good but how i am gonna write it in file. I mean you dont use file.