Board index » cppbuilder » problem with insert/get image in MSSQL2K using ADO & C++ Builder 6

problem with insert/get image in MSSQL2K using ADO & C++ Builder 6


2005-05-30 02:54:51 AM
cppbuilder35
Does anyone knows why this doesn't work ? Please :(
table->Insert(); // table: TADOTable
...
TMemoryStream *ms=new TMemoryStream();
Image1->Picture->Bitmap->SaveToStream(ms); // Image1: TImage
component
try
{
((TBlobField*)table->Fields->Fields[4])->LoadFromStream(ms);
}
__finally
{
delete ms;
}
table->Post();
 
 

Re:problem with insert/get image in MSSQL2K using ADO & C++ Builder 6

I have this saved in my archive, for similar approach connected
to TRichEdit. It's *untested*:
<quote>
TMemoryStream* MemStream = new TMemoryStream();
RichEdit1->SaveToStream( MemStream );
MemStream->Seek( 0, soFromBeginning );
TBlobStream* DBStream = (TBlobStream*) DataSet1->CreateBlobStream(
DataSet1->FieldByName("field name"), bmReadWrite );
DBStream->CopyFrom( MemStream, MemStream->Size );
DataSet1->Post();
delete MemStream;
delete DBStream;
</quote>
--
Best regards,
Vladimir Stefanovic
"Daniel Stevanovic" < XXXX@XXXXX.COM >wrote in message
Quote
Does anyone knows why this doesn't work ? Please :(

table->Insert(); // table: TADOTable
...
TMemoryStream *ms=new TMemoryStream();
Image1->Picture->Bitmap->SaveToStream(ms); // Image1: TImage
component
try
{
((TBlobField*)table->Fields->Fields[4])->LoadFromStream(ms);
}
__finally
{
delete ms;
}

table->Post();



 

Re:problem with insert/get image in MSSQL2K using ADO & C++ Builder 6

Try ms->Seek(0, soFromBeginning) after save.
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Daniel Stevanovic" < XXXX@XXXXX.COM >сообщи?сообщила ?новостях
следующе? news: XXXX@XXXXX.COM ...
Quote
Does anyone knows why this doesn't work ? Please :(

table->Insert(); // table: TADOTable
...
TMemoryStream *ms=new TMemoryStream();
Image1->Picture->Bitmap->SaveToStream(ms); // Image1: TImage
component
try
{
((TBlobField*)table->Fields->Fields[4])->LoadFromStream(ms);
}
__finally
{
delete ms;
}

table->Post();



 

{smallsort}

Re:problem with insert/get image in MSSQL2K using ADO & C++ Builder 6

Thank you.
Quote
Try ms->Seek(0, soFromBeginning) after save.
That was the problem. I figure it out last night.
"Viatcheslav V. Vassiliev" < XXXX@XXXXX.COM >wrote in message
Quote
Try ms->Seek(0, soFromBeginning) after save.

//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Daniel Stevanovic" < XXXX@XXXXX.COM >сообщи?сообщила ?новостях
следующе? news: XXXX@XXXXX.COM ...
>Does anyone knows why this doesn't work ? Please :(
>
>table->Insert(); // table: TADOTable
>...
>TMemoryStream *ms=new TMemoryStream();
>Image1->Picture->Bitmap->SaveToStream(ms); // Image1: TImage
>component
>try
>{
>((TBlobField*)table->Fields->Fields[4])->LoadFromStream(ms);
>}
>__finally
>{
>delete ms;
>}
>
>table->Post();
>
>
>