Hola ralmic.
La función que hice no agrega comillas, pero con un simple cambio podes indicarle el formato que deseas:
Código:
void QueryToTxt(TQuery *qy, const String aFileName, const String Quote)
{
String tmp;
TStrings *sl = new TStringList;
__try {
qy->Close();
qy->Open();
while (!qy->Eof) {
tmp = "";
for(int i=0; i<qy->Fields->Count; i++)
tmp += Format("%s%s%s,", ARRAYOFCONST(((String)Quote,
(String)qy->Fields->Fields[i]->AsString, (String)Quote)));
tmp.SetLength(tmp.Length()-1);
sl->Add(tmp);
qy->Next();
}
qy->Close();
sl->SaveToFile(aFileName);
} __finally {
delete sl;
}
}
Ejemplo:
Código:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
...
// Sin comillas
QueryToTxt(Query1, "C:\\Pruebas\\NoQuote.txt","");
// Con comillas simples
QueryToTxt(Query1, "C:\\Pruebas\\SingleQuote.txt",'\'');
// Con comillas dobles
QueryToTxt(Query1, "C:\\Pruebas\\DoubleQuote.txt",'"');
}
Saludos