BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Storing a TClientDataSet in a Blob Field Problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Kyle A. Miller
Guest





PostPosted: Tue Oct 07, 2003 6:28 pm    Post subject: Storing a TClientDataSet in a Blob Field Problem Reply with quote



I have an in memory table of data using the TClientDataSet. I want to
save its contents in a blob field via parameterized TClientDataSet.

When I save it, I call TClientDataSet's SaveToStream passing it a memory
stream where Position=0. It seems to be getting there, because I know
the field's value in the DB is no longer Null.

I restore the data by calling TParam's SaveToStream method passing it a
memory stream. I reset the Stream's postition to 0, call the
LoadFromStream method of another TClientDataSet, and I receive a
"Mismatch in datapacket." error.

Is there a better way to do this?

Here's the READ code...

with dstINI
do try
ParamByName(sSysIniSectionName).AsString := TRex.ApplicationCD
+ '_SETTINGS';
ParamByName(sSysUserName).AsString := User.UserName;
GET_SQL_RECORDS(dstINI, dstINI.CommandText,
conWorkstation.DataAccess, ModuleCDs[dstINI.Module]);

if FieldByName('SYS_USER_SECTION_VALUES').IsNull
then exit;

(FieldByName('SYS_USER_SECTION_VALUES') as
TBlobField).SaveToStream(Settings);
finally
Close;
end;

with cdsGeneral
do begin
Settings.Position := 0;
LoadFromStream(Settings); // <--- ERROR "Mismatch in datapacket."
end;

Here's the WRITE code...

with lDataSet do
begin
Settings := TMemoryStream.Create;
try
dstSettings.SaveToStream(Settings, dfBinary);
Settings.Position := 0;
ParamByName(sSysIniSectionName).AsString := SectionName;
ParamByName(sSysUserName).AsString := User.UserName;
ParamByName(sSectionValues).LoadFromStream(Settings, ftBlob);
conWorkstation.DataAccess.ExecSQL(ModuleCDs[lDataSet.Module],
lDataSet.CommandText, PackageParams(lDataSet.Params), RecsAffected);
finally
Settings.Free;
end;
end;

Back to top
Kyle A. Miller
Guest





PostPosted: Tue Oct 07, 2003 7:16 pm    Post subject: Re: Storing a TClientDataSet in a Blob Field Problem Reply with quote



Hmmm, well the exact same code works if I save the clientdataset's
stream as XML, but not binary. I would prefer binary because it should
be more efficient in storage space.

FYI if this sheds any light, the dataset being stored has two blob
fields, and it's is being stored in a IB/Firebird blob field.

Back to top
Robert Cerny
Guest





PostPosted: Fri Oct 10, 2003 2:28 pm    Post subject: Re: Storing a TClientDataSet in a Blob Field Problem Reply with quote



Either the field is char blob instead of binary blob, or you were shot by
variants bug where it truncates value, if it contains a null char.

--
Robert Cerny
DelphiShaman

"Kyle A. Miller" <kyle (AT) millerdevelopmentXREMOVE (DOT) info> wrote

Quote:
Hmmm, well the exact same code works if I save the clientdataset's
stream as XML, but not binary. I would prefer binary because it should
be more efficient in storage space.

FYI if this sheds any light, the dataset being stored has two blob
fields, and it's is being stored in a IB/Firebird blob field.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.