Subject | Re: [IBO] POSTING DATA from a TIBOQUERY Field inhibits use of the Query fields. (with image) |
---|---|
Author | Delmar Wichnieski (Delta Corporation) |
Post date | 2006-11-04T00:46:56Z |
Hi all
Firts
I tried, but I am getting no success. See my code over/under doubleclick of
cxDBImage where I'm tried four situations:
Tip: My cxDBImage is Dataware.
procedure TForm1.cxDBImage1DblClick(Sender: TObject);
var
Jpg:TjpegImage;
MemoryStream:TMemoryStream;
BlobStream:TBlobStream;
Stream:Tstream;
begin
try
opendialog1.Execute;
Jpg:=TjpegImage.Create;
jpg.LoadFromFile(opendialog1.FileName);
if jpg<>nil then
showmessage('jpg preenchida');
MemoryStream:=TMemoryStream.Create;
jpg.SaveToStream(MemoryStream);
MemoryStream.Seek(soFromBeginning, 0);
if MemoryStream<>nil then
showmessage('MemoryStream preenchida');
{ Stream := iboquery1.CreateBlobStream(iboquery1FOTO, bmReadWrite);
jpg.SaveToStream(Stream);
Stream.Seek(soFromBeginning,0);
if Stream<>nil then
showmessage('Stream preenchida'); }
BlobStream := TblobStream(iboquery1.CreateBlobStream(iboquery1FOTO,
bmReadWrite));
BlobStream.CopyFrom (MemoryStream,0);
BlobStream.Seek(soFromBeginning,0);
if BlobStream<>nil then
showmessage('BlobStream preenchida');
// iboquery1FOTO.assign(jpg); // save in database my informations and
image, but in my interface dbedits and dbgrids lost informations
// iboquery1FOTO.LoadFromStream(memoryStream); // save in database the
informations and image, but in my interface dbedits and dbgrid lost
informations
// iboquery1FOTO.LoadFromStream(Stream); //dont load image, dont
save image, but the record is salved
iboquery1FOTO.LoadFromStream(BlobStream); //dont load image, dont
save image, but the record is salved
except
showmessage('problems');
jpg.Free;
MemoryStream.Free;
BlobStream.Free;
// Stream.Free;
raise;
end;
jpg.Free;
MemoryStream.Free;
BlobStream.Free;
// Stream.Free;
end;
Tip: Delphi Help recomend use Tdataset.CreateBlobStream instead of
TblobStream.create, but I have seen that TIBOquery.CreateBlobStream
function dont create TBlobstream, but Tstream. Because, I do typecast
Can you help me, because appears that BlobStream is not functioning?
Thanking you very much
Delmar
Firts
> 1. Your set has only one possible record (SELECT FIRST 1). ThisI put FIRTS 1,000 then
> means that, when the dataset is refreshed, you will not see your new
> record. The dataset will always return that same record, i.e. the FIRST
> 1.
I tried, but I am getting no success. See my code over/under doubleclick of
cxDBImage where I'm tried four situations:
Tip: My cxDBImage is Dataware.
procedure TForm1.cxDBImage1DblClick(Sender: TObject);
var
Jpg:TjpegImage;
MemoryStream:TMemoryStream;
BlobStream:TBlobStream;
Stream:Tstream;
begin
try
opendialog1.Execute;
Jpg:=TjpegImage.Create;
jpg.LoadFromFile(opendialog1.FileName);
if jpg<>nil then
showmessage('jpg preenchida');
MemoryStream:=TMemoryStream.Create;
jpg.SaveToStream(MemoryStream);
MemoryStream.Seek(soFromBeginning, 0);
if MemoryStream<>nil then
showmessage('MemoryStream preenchida');
{ Stream := iboquery1.CreateBlobStream(iboquery1FOTO, bmReadWrite);
jpg.SaveToStream(Stream);
Stream.Seek(soFromBeginning,0);
if Stream<>nil then
showmessage('Stream preenchida'); }
BlobStream := TblobStream(iboquery1.CreateBlobStream(iboquery1FOTO,
bmReadWrite));
BlobStream.CopyFrom (MemoryStream,0);
BlobStream.Seek(soFromBeginning,0);
if BlobStream<>nil then
showmessage('BlobStream preenchida');
// iboquery1FOTO.assign(jpg); // save in database my informations and
image, but in my interface dbedits and dbgrids lost informations
// iboquery1FOTO.LoadFromStream(memoryStream); // save in database the
informations and image, but in my interface dbedits and dbgrid lost
informations
// iboquery1FOTO.LoadFromStream(Stream); //dont load image, dont
save image, but the record is salved
iboquery1FOTO.LoadFromStream(BlobStream); //dont load image, dont
save image, but the record is salved
except
showmessage('problems');
jpg.Free;
MemoryStream.Free;
BlobStream.Free;
// Stream.Free;
raise;
end;
jpg.Free;
MemoryStream.Free;
BlobStream.Free;
// Stream.Free;
end;
Tip: Delphi Help recomend use Tdataset.CreateBlobStream instead of
TblobStream.create, but I have seen that TIBOquery.CreateBlobStream
function dont create TBlobstream, but Tstream. Because, I do typecast
Can you help me, because appears that BlobStream is not functioning?
Thanking you very much
Delmar
----- Original Message -----
From: "Helen Borrie" <helebor@...>
To: <IBObjects@yahoogroups.com>
Sent: Thursday, November 02, 2006 7:31 PM
Subject: Re: [IBO] POSTING DATA from a TIBOQUERY Field inhibits use of the
Query fields. (with image)
> At 06:06 AM 3/11/2006, you wrote:
>>Hi All,
>>
>>I have the same problem when my TiboQuery is in dsinsert state, but only
>>because my program have an IMAGE blob field 80 binary. If I don't load an
>>image, all right. But if I load an image, the record is inserted, saved in
>>database, but lost informations im my DBedits e DBgrid although the record
>>remain.
>
> Your problem has two causes.
>
> 1. Your set has only one possible record (SELECT FIRST 1). This
> means that, when the dataset is refreshed, you will not see your new
> record. The dataset will always return that same record, i.e. the FIRST
> 1.
>
> 2. A blob is not an ordinary database field, it is a "soup of
> bytes". The database cannot store it unless you first convert it to
> a blob. This is easier to do in native IBO than in the
> VCL-compatible components, but you can do it. In native IBO you can
> assign an image object directly to a field of type
> TIB_ColumnBlob. In the VCL, the steps are not as well
> encapsulated: you need to assign your image object to a stream and
> then assign that stream to a TBlobStream, then assign that to your
> TBlobField. See the Delphi help on these two classes.
>
> (Note also that your blob is NOT an "IMAGE blob field 80 binary", it
> is an untyped soup of bytes of unknown size. The "SEGMENT SIZE 80"
> in your declaration is an irrelevant artifact.)
>
> - please see further comments in-line.
>
>
>>See my SQL Select
>>
>>SELECT FIRST 1
>> CLIENTE.CODIGO
>> , CLIENTE.CLIENTE
>> , CLIENTE.CONTATO
>> , CLIENTE.TIPO
>> , CLIENTE.CNPJ
>> , CLIENTE.IE
>> , CLIENTE.CPF
>> , CLIENTE.CI
>> , CLIENTE.ENDERECO
>> , CLIENTE.COMPLEMENTO
>> , CLIENTE.CODBAIRRO
>> , CLIENTE.CODCIDADE
>> , CLIENTE.CEP
>> , CLIENTE.FONE
>> , CLIENTE.FAX
>> , CLIENTE.DESDE
>> , CLIENTE.ANIVERSARIO
>> , CLIENTE.CONTATO1
>> , CLIENTE.EMAIL1
>> , CLIENTE.MSN1
>> , CLIENTE.SKYPE1
>> , CLIENTE.FONECONTATO1
>> , CLIENTE.CONTATO2
>> , CLIENTE.EMAIL2
>> , CLIENTE.MSN2
>> , CLIENTE.SKYPE2
>> , CLIENTE.FONECONTATO2
>> , CLIENTE.LIMITEVALORFATUR
>> , CLIENTE.RESPFINANFATUR
>> , CLIENTE.FOTO
>> , CLIENTE.OBS
>> , BAIRRO.BAIRRO
>> , CIDADE.CIDADE
>> , CIDADE.UF
>>FROM CLIENTE
>>LEFT JOIN BAIRRO ON CLIENTE.CODBAIRRO=BAIRRO.CODIGO
>>LEFT JOIN CIDADE ON CLIENTE.CODCIDADE=CIDADE.CODIGO
>>ORDER BY CLIENTE.CODIGO
>>
>>See my SLQ Insert:
>>
>>INSERT INTO CLIENTE(
>> CODIGO,
>> CLIENTE,
>> CONTATO,
>> TIPO,
>> CNPJ,
>> IE,
>> CPF,
>> CI,
>> ENDERECO,
>> COMPLEMENTO,
>> CODBAIRRO,
>> CODCIDADE,
>> CEP,
>> FONE,
>> FAX,
>> DESDE,
>> ANIVERSARIO,
>> CONTATO1,
>> EMAIL1,
>> MSN1,
>> SKYPE1,
>> FONECONTATO1,
>> CONTATO2,
>> EMAIL2,
>> MSN2,
>> SKYPE2,
>> FONECONTATO2,
>> LIMITEVALORFATUR,
>> RESPFINANFATUR,
>> FOTO,
>> OBS)
>>VALUES (
>> :CODIGO,
>> :CLIENTE,
>> :CONTATO,
>> :TIPO,
>> :CNPJ,
>> :IE,
>> :CPF,
>> :CI,
>> :ENDERECO,
>> :COMPLEMENTO,
>> :CODBAIRRO,
>> :CODCIDADE,
>> :CEP,
>> :FONE,
>> :FAX,
>> :DESDE,
>> :ANIVERSARIO,
>> :CONTATO1,
>> :EMAIL1,
>> :MSN1,
>> :SKYPE1,
>> :FONECONTATO1,
>> :CONTATO2,
>> :EMAIL2,
>> :MSN2,
>> :SKYPE2,
>> :FONECONTATO2,
>> :LIMITEVALORFATUR,
>> :RESPFINANFATUR,
>> :FOTO,
>> :OBS)
>
> You will need to code the "business" for passing your image into your
> FOTO object during the BeforePost.
>
>>Some configurations
>>isolation = tiCommitted
>>CommitAction=caInvalidateCursor
>>Autocommit = I Try with true and false
>
> Tip: Make Autocommit false always when working with large
> blobs. When updating and deleting records with blobs, Autocommit
> causes a large build-up of garbage that can use up a lot of resources.
>
> Helen
>
>
>
> ___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
> InterBase
> without the need for BDE, ODBC or any other layer.
> ___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info
> papers,
> keyword-searchable FAQ, community code contributions and more !
> Yahoo! Groups Links
>
>
>
>
> __________ Informação do NOD32 IMON 1.1850 (20061102) __________
>
> Esta mensagem foi verificada pelo NOD32 sistema antivírus
> http://www.eset.com.br
>
>