 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kyle A. Miller Guest
|
Posted: Tue Oct 07, 2003 6:28 pm Post subject: Storing a TClientDataSet in a Blob Field Problem |
|
|
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
|
Posted: Tue Oct 07, 2003 7:16 pm Post subject: Re: Storing a TClientDataSet in a Blob Field Problem |
|
|
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
|
Posted: Fri Oct 10, 2003 2:28 pm Post subject: Re: Storing a TClientDataSet in a Blob Field Problem |
|
|
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 |
|
 |
|
|
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
|
|