Different codings on different computers
Posted: Fri 08 May 2009 10:54
On MS SQL Server 2008 there is a stored procedure returning the table in a kind of a xml-text:
On client there is an object TMSStoredProc to save stored procs' results to a file.
If I save the data to a file so:
Then file is normal xml-table which is able to open any TClientDataSet. Such code is not good.
But if I save the data to a file so:
Begins any mysticism. On my computer (WinXP) this program normally creates the same xml-file, but in working system (Windows 2003 Server, Windows 2008 Server) in the file is any another coding (maybe UNICODE?), data writing per 2 bytes on char (on text view "< D A T A P A C K E T", but not "<DATAPACKET"), and no any TClientDataSet may open this file. Why so?
Code: Select all
CREATE PROCEDURE [dbo].[atisp_GetCreateTable](@FieldsAttrs VARCHAR(5000), @Fields VARCHAR(2500), @TableName VARCHAR(40), @IxCount INT) AS BEGIN
DECLARE @S VARCHAR(8000), @BeforeXML VARCHAR(60), @BetweenXML VARCHAR(40), @AfterXML VARCHAR(120);
SET @BeforeXML='select CAST(''';
SET @BetweenXML='''+isnull((';
SET @AfterXML=' for xml path(''ROW''), root(''ROWDATA'')), '''') + '''' as xml)';
SET @S='SELECT '+@Fields+' FROM '+@TableName;
IF @IxCount=1
SET @S=@S+' ORDER BY 1'
ELSE
SET @S=@S+' ORDER BY 1,2';
SET @S=@BeforeXML+@FieldsAttrs+@BetweenXML+@S+@AfterXML;
EXEC(@S)
END
ENDIf I save the data to a file so:
Code: Select all
F:=TFileStream.Create(TblFileName,fmCreate);
with F do try
s:=FMSProc.Fields[0].AsString;
s:=''+s;
i:=Length(s);
F.Write(s[1],I)
finally
Free
endBut if I save the data to a file so:
Code: Select all
F:=TFileStream.Create(TblFileName,fmCreate);
with F do try
s:='';
i:=Length(s);
F.Write(s[1],I);
TBlobField(FMSProc.Fields[0]).SaveToStream(F);
finally
Free
end