Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TIBBlobStream

49 views
Skip to first unread message

Bennie Coetzer

unread,
Aug 6, 2008, 9:37:53 AM8/6/08
to
I would like to save pictures in a database and have successfully done this
with DBExpress, but the same technique of using parameters in my queries
don't seem to work.
Does anyone have an example of how to use TIBBlobstream to get Blobs in and
out of a DB and also how to set up the queries
OR
Can someone point me to some documentation which describes this
I am using BDS2006 and program in Delphi


Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 9:51:12 AM8/6/08
to
Bennie Coetzer wrote:

> I would like to save pictures in a database and have successfully
> done this with DBExpress, but the same technique of using parameters
> in my queries don't seem to work.

It should. If you want help fixing your code, it would be good to
show the code that does not work.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
IB 6 versions prior to 6.0.1.6 are pre-release and may corrupt
your DBs! Open Edition users, get 6.0.1.6 from http://mers.com

Bennie Coetzer

unread,
Aug 6, 2008, 10:21:29 AM8/6/08
to
Hi Craig
Herewith the offending code. I may add that I am trying Delphi for .NET.

qry_RefQry.close;
qry_RefQry.UnPrepare;
qry_RefQry.SQL.Clear;
qry_RefQry.SQL.Add(
'UPDATE CAMREFTBL ' +
' SET REFIMG = :IMAGE' +
', REFTHUMB = :IMAGETHUMB' +
' WHERE CAM_ID = ' + '''' + inttostr(CamID) + '''');
qry_RefQry.Params[0].LoadfromFile(ScratchPath + 'XRefGrab.bmp', ftBlob);
qry_RefQry.Params[1].LoadFromFile(ScratchPath + 'YRefGrab.bmp', ftBlob);
qry_RefQry.Prepare;
try
qry_RefQry.ExecSQL;
except
on E: Exception do
MessageDlg('Update DB IMG Error', mtWarning, [mbOK], 0);
end;

Thanks

"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote
in message news:4899...@newsgroups.borland.com...

Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 10:24:26 AM8/6/08
to
Bennie Coetzer wrote:

> Herewith the offending code.

...and the problem is?

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Useful articles about InterBase development:
http://blogs.teamb.com/craigstuntz/category/21.aspx

Bennie Coetzer

unread,
Aug 6, 2008, 12:58:15 PM8/6/08
to
It creates an exception error when I open the qry

"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote

in message news:4899b41a$1...@newsgroups.borland.com...

Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 12:59:52 PM8/6/08
to
Bennie Coetzer wrote:

> It creates an exception error when I open the qry

<sigh>

What is the error, please?

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

How to ask questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html

Bennie Coetzer

unread,
Aug 6, 2008, 1:56:37 PM8/6/08
to
I am not sure how to trap the error but added a 'raise' command in the
except portion of the try. I got the following error

"Object reference not set to an instance of an object"

Updating values in the value fields of the table had no problems


"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote

in message news:4899d888$1...@newsgroups.borland.com...

Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 2:09:04 PM8/6/08
to
Bennie Coetzer wrote:

> "Object reference not set to an instance of an object"
>
> Updating values in the value fields of the table had no problems

On which line? That's a null reference exception. When you debug
this code, which identifier is nil before the exception is raised?

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Want to help make Delphi and InterBase better? Use QC!
http://qc.borland.com -- Vote for important issues

Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 2:30:38 PM8/6/08
to
Bennie Coetzer wrote:

> I added the raise in the try statement as follows

OK, get rid of the except block and post the call stack, so I can see
what is raising the error.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Bennie Coetzer

unread,
Aug 6, 2008, 2:33:37 PM8/6/08
to
Sorry I don't understand - how do I I get the call stack. When I remove the
except block I just get the error and the program continues

"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote

in message news:4899edce$1...@newsgroups.borland.com...

Bennie Coetzer

unread,
Aug 6, 2008, 2:20:32 PM8/6/08
to
Hi Craig

I added the raise in the try statement as follows

try


qry_RefQry.ExecSQL;
except
on E: Exception do

begin


MessageDlg('Update DB IMG Error', mtWarning, [mbOK], 0);

raise; <------- THIS IS WHERE THE ERROR IS SHOWN
end;
end;


"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote

in message news:4899e8c0$1...@newsgroups.borland.com...

Bennie Coetzer

unread,
Aug 6, 2008, 2:50:38 PM8/6/08
to
I hope this is what you're looking for?

Borland.Vcl.Units.IBBlob::WriteBlob()
Borland.Vcl.TIBBlobStream::FinalizeBlob()
Borland.Vcl.TIBXSQLVAR::LoadFromStream()
Borland.Vcl.TIBXSQLVAR::SetAsString()
Borland.Vcl.TIBXSQLVAR::set_AsString()
Borland.Vcl.TIBQuery::SetParams()
Borland.Vcl.TIBQuery::ExecSQL()
ATCamProcess.TTestProc::AddResultToDB()
ATCamProcess.TTestProc::ExecGetRef()
ATMain.TfmATMain::SetCamRef()
ATMain.TfmATMain::sbCalibrateClick()
Borland.Vcl.TControl::Click()
Borland.Vcl.TSpeedButton::Click()
Borland.Vcl.TSpeedButton::MouseUp()
Borland.Vcl.TControl::DoMouseUp()
Borland.Vcl.TControl::WMLButtonUp()
System.Reflection.RuntimeMethodInfo::InternalInvoke()
System.Reflection.RuntimeMethodInfo::Invoke()
System.Reflection.MethodBase::Invoke()
System.Reflection.MethodInfo::Invoke()
Borland.Delphi.TObjectHelper::Dispatch()
Borland.Vcl.TControl::Dispatch()
Borland.Vcl.TControl::WndProc()
Borland.Vcl.TControl::Perform()
Borland.Vcl.TWinControl::IsControlMouseMsg()
Borland.Vcl.TWinControl::WndProc()
Borland.Vcl.TWinControl::MainWndProc()
Borland.Vcl.TObjectInstance$WinUtils::WndProc()
Borland.Vcl.TApplication::ProcessMessage()
Borland.Vcl.TApplication::HandleMessage()
Borland.Vcl.TApplication::Run()
prjAutoTech.Units.prjAutoTech::prjAutoTech()

"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote

in message news:4899ef9f$1...@newsgroups.borland.com...


> Bennie Coetzer wrote:
>
>> Sorry I don't understand - how do I I get the call stack.
>

> Ctrl+Alt+S when stopped in the debugger.


>
>> When I
>> remove the except block I just get the error and the program continues
>

> Turn on stop on exceptions in the debug options.


>
> --
> Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
> Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 2:38:23 PM8/6/08
to
Bennie Coetzer wrote:

> Sorry I don't understand - how do I I get the call stack.

Ctrl+Alt+S when stopped in the debugger.

> When I


> remove the except block I just get the error and the program continues

Turn on stop on exceptions in the debug options.

--

Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Craig Stuntz [TeamB]

unread,
Aug 6, 2008, 3:07:52 PM8/6/08
to
Bennie Coetzer wrote:

> Borland.Vcl.TIBXSQLVAR::SetAsString()
> Borland.Vcl.TIBXSQLVAR::set_AsString()

Well, you have a JPEG, not a string. Maybe ftBlob is treating your
file like a string, and truncating when it sees a #0. Try one of the
other types, or loading into a TMemoryStream first and then using
TParam.LoadFromStream

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Jean-Noël Voirol

unread,
Aug 7, 2008, 7:52:58 AM8/7/08
to
This is the way i'm doing it:


FStream.Clear;
FStream.Position:=0;
s:=FUrl;
if FParam<>'' then s:=s+'?'+Fparam;
idhttp.get(s,Fstream);
if idhttp.Response.ResponseCode=200 then
begin
FErrorCode:=0;
if idhttp.Response.ContentType='image/jpeg' then
begin
FStream.Position:=0;
if IBConnected then
begin
Fquery:=AxisCreateQuery;
try
try
with FQuery do
begin
sql.Clear;
sql.add('INSERT INTO VK_IMAGES (AXIS_IMAGE) VALUES (:MYIMAGE) ');
paramByName('MYIMAGE').LoadFromStream(FStream,ftBlob);
ExecSql;
end;
except
on e:exception do
begin
.....


Jean-Noël

Bennie Coetzer

unread,
Aug 7, 2008, 8:39:37 AM8/7/08
to
Hi
Thanks Jean-Noel
Is FStream a TIBBlobstream or a TMemorystream?
Bennie

"Jean-Noël Voirol" <"jnvk["@]vkvision[.]ch> wrote in message
news:489a...@newsgroups.borland.com...

Jean-Noël Voirol

unread,
Aug 7, 2008, 11:43:49 AM8/7/08
to
Bennie Coetzer a écrit :

> Hi
> Thanks Jean-Noel
> Is FStream a TIBBlobstream or a TMemorystream?
> Bennie

It is a TMemoryStream in my case.


0 new messages