حفظ نتيجة Query في ملف
#2
وجدت طريقتين :

الأولى :

PHP كود :
var   Stream: TFileStream;
 
i: Integer;
  
OutLine: string;
  
sTemp: string;
  
begin   Stream := TFileStream.Create('C:\fichierFinal1.csv', fmCreate);
 try     while 
not zQuery1.Eof do
 
begin
 
// You'll need to add your special handling here where OutLine is built
 
OutLine := '';
for 
i := 0 to zQuery1.FieldCount - 1 do
 
begin         sTemp := ZQuery1.Fields[i].AsString;
// Special handling to sTemp here
 
OutLine := OutLine + sTemp + ',';
 
end;
// Remove final unnecessary ','
SetLength(OutLine, Length(OutLine) - 1);
 
// Write line to file
 
Stream.Write(OutLine[1], Length(OutLine) * SizeOf(Char));
 
// Write line ending
 
Stream.Write(sLineBreak, Length(sLineBreak));
 
zQuery1.Next;
 
end;
 finally
 
Stream.Free;  // Saves the file
  
end;
end; 
الثانية:

PHP كود :
var
List: 
TStringList;
  
S: String;
   
I: Integer;
 
begin
List := TStringList.Create;
try     
ZQuery1.First;
 while 
not ZQuery1.Eof do
 
begin
  S 
:= '';
for 
I := 0 to ZQuery1.FieldCount - 1 do
 
begin
 
if S > '' then
  S 
:= S + ',';
  
S := S + ZQuery1.Fields[I].AsString ;
 
end;
 List.
Add(S);
ZQuery1.Next;
 
end;
 finally
 List.
SaveToFile('C:\fichierFinal.csv');
  List.
Free;
  
end;
 
end; 
أدبني الدهر فأراني نقص عقلي وإذا ما ازددت علما زادني علما بجهلي
الرد


الردود في هذا الموضوع
حفظ نتيجة Query في ملف - بواسطة لؤي - 12-03-2012, 09:19 AM
حفظ نتيجة Query في ملف - بواسطة لؤي - 12-03-2012, 09:52 AM
حفظ نتيجة Query في ملف - بواسطة kachwahed - 12-03-2012, 06:31 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم