Okay so I am writing a program that imports a database to an text file Via (SaveToFile command) .But when I open the file normally it gives me.
TG! ¶’ò?²Ï# ª _þX g ÒcöëÏ°ã ª ? Á<Ž¶ëmÐö ª _þX
| ¾"µÈó\Îå ª Dw= ÿÿ† ÿÿ" I Á<Ž¶ëmÐö ª _þX 2 . " C l i e n t s " C l i e n t s + ð I D I D
ÿ Z ÿÿÿÿC ð S u r e n a m e S u r e n a m e ‚ ÿ ÿ j ÿÿC ð P a s s w o r d P a s s w o r d
ÿ z ÿÿ3 ð N a m e N a m e ‚ ÿ ÿ j ÿÿK ð
M o n e y P a i d
M o n e y P a i d ÿ z ÿÿK ð
M o n e y O w e d
M o n e y O w e d ÿ z ÿÿ[ ð O n c e O f f C l i e n t O n c e O f f C l i e n t ÿ ÿ Z ÿÿC ð P h o n e I D P h o n e I D
ÿ z ÿÿÿ a w e a w e Ó–I
Here is my code:
procedure TfrmRawDATA.btnStoreFeedClick(Sender: TObject);
var
StoreFeed : string;
StoreFeedFile: TextFile;
data : string;
begin
begin
if (FileExists('C:\Users\ASROCK\Desktop\IT-PAT 2014\PAT Fase 3\StoreFeedFile.txt')) then
begin
DeleteFile('C:\Users\ASROCK\Desktop\IT-PAT 2014\PAT Fase 3\StoreFeedFile.txt');
ShowMessage('Save file deleted!');
end
else
AssignFile(StoreFeedFile,'Test.txt');
FileSetAttr('C:\Users\ASROCK\Desktop\IT-PAT 2014\PAT Fase 3\StoreFeedFile.txt', faReadOnly);
dmMJCPlus.tblClients.SaveToFile('C:\Users\ASROCK\Desktop\IT-PAT 2014\PAT Fase 3\StoreFeedFile.txt');
end;
end;
I just wanna know how to set like the file type or something so it doesn't give me that text.
The default saving format for ADO table/query and ClientDataSet is binary. You have the option of using XML though. You need to specify it in the call to SaveToFile
:
ClientDataSet.SaveToFile('...', dfXML);
or
ADOTable.SaveToFile('...', pfXML);
Having a file extension of '.xml' should achieve the same, looking at the source, though it would seem it didn't turn out to be the case for you (as you seem to have tried it in the comments).
pfXML
/dfXML
are defined in 'adodb.pas' and 'dbclient.pas' respectively.