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 

Retrieving Blob objects

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Javier Aguirre
Guest





PostPosted: Wed Jun 15, 2005 3:47 pm    Post subject: Retrieving Blob objects Reply with quote



Greetings
I hope someone can help me with this...
I have diferent kind of documents in a blob field in a Access database.
My problem is when I try to retrieve and show them, because the program don't
know what kind is the file stored in the field, I want to use the TOLEContainer
to show the file contents as the Access forms do, so I use streams to pass the
data from the field to the container but I only get errors of insufficent memory
or incompatible stream format.
I try with the LoadFromStream and LoadFromFile using as example the code of the
original component and get nothing.

Here is an example of my code:

procedure TForm1._OnActivate(Sender: TObject);
begin
Blob:=TBlobField.Create(Data.adoTarticulo);
Blob.FieldName:='Documento';
Blob.Name:=Data.adoTarticulo.name+Blob.FieldName;
Blob.Index:=Data.adoTarticulo.FieldCount;
Blob.DataSet:=Data.adoTarticulo;
Data.Documentos.Open;
Data.adoTarticulo.Open;
end;

procedure TForm1._Registros(Sender: TObject; Button: TNavigateBtn);
var
Buffer : TAdoBlobStream; // I use TMemoryStream, TStream, and other
// compatible objets and nothing happens
Tamano : integer;
begin
if not Blob.IsNull then
with Data.adoTArticulo do
begin
if not(Active) then Open;
Buffer:=TAdoBlobStream.Create(Blob,bmRead);
Blob.SaveToStream(buffer);
try
Ole1.LoadFromStream(Buffer); // Here is where I get the error
Ole1.DoVerb(ovShow);
finally
Buffer.Free;
end;
end;
end;

Please, I appreciate any idea to resolve this...

Thanks

Javier
Back to top
Mike Shkolnik
Guest





PostPosted: Thu Jun 16, 2005 11:36 am    Post subject: Re: Retrieving Blob objects Reply with quote



TOLEContainer have the own format streaming (LoadFromStream/SaveToStream).
Just save your BLOB contents to temporary file and use the
TOLEContainer.CreateObjectFromFile method instead

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Javier Aguirre" <jad (AT) ec-red (DOT) com> wrote

Quote:
Greetings
I hope someone can help me with this...
I have diferent kind of documents in a blob field in a Access database.
My problem is when I try to retrieve and show them, because the program
don't
know what kind is the file stored in the field, I want to use the
TOLEContainer
to show the file contents as the Access forms do, so I use streams to pass
the
data from the field to the container but I only get errors of insufficent
memory
or incompatible stream format.
I try with the LoadFromStream and LoadFromFile using as example the code
of the
original component and get nothing.

Here is an example of my code:

procedure TForm1._OnActivate(Sender: TObject);
begin
Blob:=TBlobField.Create(Data.adoTarticulo);
Blob.FieldName:='Documento';
Blob.Name:=Data.adoTarticulo.name+Blob.FieldName;
Blob.Index:=Data.adoTarticulo.FieldCount;
Blob.DataSet:=Data.adoTarticulo;
Data.Documentos.Open;
Data.adoTarticulo.Open;
end;

procedure TForm1._Registros(Sender: TObject; Button: TNavigateBtn);
var
Buffer : TAdoBlobStream; // I use TMemoryStream, TStream, and other
// compatible objets and nothing happens
Tamano : integer;
begin
if not Blob.IsNull then
with Data.adoTArticulo do
begin
if not(Active) then Open;
Buffer:=TAdoBlobStream.Create(Blob,bmRead);
Blob.SaveToStream(buffer);
try
Ole1.LoadFromStream(Buffer); // Here is where I get the error
Ole1.DoVerb(ovShow);
finally
Buffer.Free;
end;
end;
end;

Please, I appreciate any idea to resolve this...

Thanks

Javier



Back to top
Javier Aguirre
Guest





PostPosted: Tue Jun 21, 2005 10:01 pm    Post subject: Re: Retrieving Blob objects Reply with quote



Hello Mike
One of the problems I found with this method is I don't know the kind of object
or the original filename, in this case, how can I determine the correct type of
object?
I guess there is some method or function in the ADO interface that allow me to
retrieve the kind of data store in the BLOB field. This would be usefull to
create the file and then create the object from file...

Greetings
Javier

Mike Shkolnik wrote:
Quote:
TOLEContainer have the own format streaming (LoadFromStream/SaveToStream).
Just save your BLOB contents to temporary file and use the
TOLEContainer.CreateObjectFromFile method instead

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Javier Aguirre" <jad (AT) ec-red (DOT) com> wrote in message
news:42b04e03 (AT) newsgroups (DOT) borland.com...

Greetings
I hope someone can help me with this...
I have diferent kind of documents in a blob field in a Access database.
My problem is when I try to retrieve and show them, because the program

don't

know what kind is the file stored in the field, I want to use the

TOLEContainer

to show the file contents as the Access forms do, so I use streams to pass

the

data from the field to the container but I only get errors of insufficent

memory

or incompatible stream format.
I try with the LoadFromStream and LoadFromFile using as example the code

of the

original component and get nothing.

Here is an example of my code:

procedure TForm1._OnActivate(Sender: TObject);
begin
Blob:=TBlobField.Create(Data.adoTarticulo);
Blob.FieldName:='Documento';
Blob.Name:=Data.adoTarticulo.name+Blob.FieldName;
Blob.Index:=Data.adoTarticulo.FieldCount;
Blob.DataSet:=Data.adoTarticulo;
Data.Documentos.Open;
Data.adoTarticulo.Open;
end;

procedure TForm1._Registros(Sender: TObject; Button: TNavigateBtn);
var
Buffer : TAdoBlobStream; // I use TMemoryStream, TStream, and other
// compatible objets and nothing happens
Tamano : integer;
begin
if not Blob.IsNull then
with Data.adoTArticulo do
begin
if not(Active) then Open;
Buffer:=TAdoBlobStream.Create(Blob,bmRead);
Blob.SaveToStream(buffer);
try
Ole1.LoadFromStream(Buffer); // Here is where I get the error
Ole1.DoVerb(ovShow);
finally
Buffer.Free;
end;
end;
end;

Please, I appreciate any idea to resolve this...

Thanks

Javier




Back to top
Glenn De Tollenaere
Guest





PostPosted: Wed Jun 22, 2005 8:43 am    Post subject: Re: Retrieving Blob objects Reply with quote

Javier,

I guess this is not possible.
Wouldn't it be easier to save the extension somewhere in your databasetable,
next to the contents (BLOB) ?

For instance, add 'FILETYPE' to your databasedefinition and fill it with the
file-extension. That way you will be able to save the contents of the BLOB
to a temporary-file with the correct extension.

Regards
Glenn

"Javier Aguirre" <jad (AT) ec-red (DOT) com> wrote

Quote:
Hello Mike
One of the problems I found with this method is I don't know the kind of
object or the original filename, in this case, how can I determine the
correct type of object?
I guess there is some method or function in the ADO interface that allow
me to retrieve the kind of data store in the BLOB field. This would be
usefull to create the file and then create the object from file...

Greetings
Javier

Mike Shkolnik wrote:
TOLEContainer have the own format streaming
(LoadFromStream/SaveToStream).
Just save your BLOB contents to temporary file and use the
TOLEContainer.CreateObjectFromFile method instead

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Javier Aguirre" <jad (AT) ec-red (DOT) com> wrote in message
news:42b04e03 (AT) newsgroups (DOT) borland.com...

Greetings
I hope someone can help me with this...
I have diferent kind of documents in a blob field in a Access database.
My problem is when I try to retrieve and show them, because the program

don't

know what kind is the file stored in the field, I want to use the

TOLEContainer

to show the file contents as the Access forms do, so I use streams to
pass

the

data from the field to the container but I only get errors of insufficent

memory

or incompatible stream format.
I try with the LoadFromStream and LoadFromFile using as example the code

of the

original component and get nothing.

Here is an example of my code:

procedure TForm1._OnActivate(Sender: TObject);
begin
Blob:=TBlobField.Create(Data.adoTarticulo);
Blob.FieldName:='Documento';
Blob.Name:=Data.adoTarticulo.name+Blob.FieldName;
Blob.Index:=Data.adoTarticulo.FieldCount;
Blob.DataSet:=Data.adoTarticulo;
Data.Documentos.Open;
Data.adoTarticulo.Open;
end;

procedure TForm1._Registros(Sender: TObject; Button: TNavigateBtn);
var
Buffer : TAdoBlobStream; // I use TMemoryStream, TStream, and other
// compatible objets and nothing happens
Tamano : integer;
begin
if not Blob.IsNull then
with Data.adoTArticulo do
begin
if not(Active) then Open;
Buffer:=TAdoBlobStream.Create(Blob,bmRead);
Blob.SaveToStream(buffer);
try
Ole1.LoadFromStream(Buffer); // Here is where I get the error
Ole1.DoVerb(ovShow);
finally
Buffer.Free;
end;
end;
end;

Please, I appreciate any idea to resolve this...

Thanks

Javier




Back to top
Vitali Kalinin
Guest





PostPosted: Wed Jun 22, 2005 10:23 am    Post subject: Re: Retrieving Blob objects Reply with quote

You are wrongly manipulating with Blob stream, try to change it this way
(assuming that Blob content is valid and acceptable for TOleContainer):
procedure TForm1._Registros(Sender: TObject; Button: TNavigateBtn);
var
Buffer : TAdoBlobStream; // I use TMemoryStream, TStream, and other
// compatible objets and nothing happens
Tamano : integer;
begin
if not Blob.IsNull then
with Data.adoTArticulo do
begin
if not(Active) then Open;
Buffer := CreateBlobStream(Blob, bmRead);
try
Ole1.LoadFromStream(Buffer);
Ole1.DoVerb(ovShow);
finally
Buffer.Free;
end;
end;
end;


"Javier Aguirre" <jad (AT) ec-red (DOT) com> ???????/???????? ? ???????? ?????????:
news:42b04e03 (AT) newsgroups (DOT) borland.com...
Quote:
Greetings
I hope someone can help me with this...
I have diferent kind of documents in a blob field in a Access database.
My problem is when I try to retrieve and show them, because the program
don't
know what kind is the file stored in the field, I want to use the
TOLEContainer
to show the file contents as the Access forms do, so I use streams to pass
the
data from the field to the container but I only get errors of insufficent
memory
or incompatible stream format.
I try with the LoadFromStream and LoadFromFile using as example the code
of the
original component and get nothing.

Here is an example of my code:

procedure TForm1._OnActivate(Sender: TObject);
begin
Blob:=TBlobField.Create(Data.adoTarticulo);
Blob.FieldName:='Documento';
Blob.Name:=Data.adoTarticulo.name+Blob.FieldName;
Blob.Index:=Data.adoTarticulo.FieldCount;
Blob.DataSet:=Data.adoTarticulo;
Data.Documentos.Open;
Data.adoTarticulo.Open;
end;

procedure TForm1._Registros(Sender: TObject; Button: TNavigateBtn);
var
Buffer : TAdoBlobStream; // I use TMemoryStream, TStream, and other
// compatible objets and nothing happens
Tamano : integer;
begin
if not Blob.IsNull then
with Data.adoTArticulo do
begin
if not(Active) then Open;
Buffer:=TAdoBlobStream.Create(Blob,bmRead);
Blob.SaveToStream(buffer);
try
Ole1.LoadFromStream(Buffer); // Here is where I get the error
Ole1.DoVerb(ovShow);
finally
Buffer.Free;
end;
end;
end;

Please, I appreciate any idea to resolve this...

Thanks

Javier



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation 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.