Subject | Blob insert woes... |
---|---|
Author | Admin |
Post date | 2001-03-16T02:11:14Z |
I wrote a routine that takes a graphic(bmp,ico,jpg,jpeg,gif) and inserts
it into an IB6 Dialect 3 blob column. This worked fine for a while, but
I must have done something to break it.
Now I can't get it to work anymore. I've tried so many ways to make this
code work that I can't begin to remember them all. So I'll include some
code from one of my latest attempts to give you an idea. I get the error
message 335544334 'conversion error from string' every time I attempt to
do an insert or append. I've had various erros during my attemts to fix
this problem - this is only the latest
Help11
TIA
David Keith
procedure TForm1.BitBtn2Click(Sender: TObject);
var
bf : TBlobField;
st : TStream;
// t1 : TIBOQuery;
// qsl : TIB_StringList;
begin
try
{ the following code is a commented out approach that doesn't
work:
qsl := TIB_StringList.Create;
t1 := TIBOQUERY.Create(Self);
t1.Databasename :=
'APPSERV:F:\IB_DB\IBTHINCLIENT\THINCLIENT.GDB';
t1.IB_Connection := ibconn1;
t1.IB_Transaction := ibt1;
t1.KeyLinks.Append('GRAPHICSTREAM.PKEY');
qsl := TIB_SQLStrings.Create;
qsl.Append('SELECT PKEY, GRAPHIC FROM GRAPHICSTREAM ');
qsl.Append('WHERE GRAPHICNAME = ''' + dbgrid1.Fields[0].AsString
+ '''');
qsl.Append(' AND VERSION = ''' + dbgrid1.Fields[1].AsString +
''';');
t1.SQL.text := qsl.Text; }
// the below listed code is the 'latest attempt' that still doesn't
work
with table1 do
begin
// st := TMemoryStream.Create;
// image.Picture.Graphic.SaveToStream(st);
bf := TBlobField.Create(Self);
bf.Fieldname := 'Graphic';
bf.Name := 'bfGraphic';
bf.Index := 1;
bf.ReadOnly := false;
close;
bf.DataSet := table1;
open;
edit;
insert;
bf.LoadFromFile(edit1.text); // edit1.text contains path
and file
// name info for graphic
FieldByName('graphicname').value :=
extractFileName(edit1.text);
FieldByName('"VERSION"').value := 1;
// := image.Picture.Graphic;
post;
end;
except
on E:EIBO_ISCError do
case E.ERRCODE of
335544665 : begin
messageBeep(0);
messageDlg('You have attempted to '
+'use an existing image '
+'name and version '
+'number. Please choose '
+'a different name for '
+'image.',mtError,
[mbCancel],0);
// t1.Close;
bf.free;
// t1.free;
end;
335544569 : begin
//resolution code here:
// t1.Close;
bf.free;
// t1.free;
showMessage('Ouch!');
end;
end;
end;
// t1.close;
bf.Free;
//t1.free;
end;
[Non-text portions of this message have been removed]
it into an IB6 Dialect 3 blob column. This worked fine for a while, but
I must have done something to break it.
Now I can't get it to work anymore. I've tried so many ways to make this
code work that I can't begin to remember them all. So I'll include some
code from one of my latest attempts to give you an idea. I get the error
message 335544334 'conversion error from string' every time I attempt to
do an insert or append. I've had various erros during my attemts to fix
this problem - this is only the latest
Help11
TIA
David Keith
procedure TForm1.BitBtn2Click(Sender: TObject);
var
bf : TBlobField;
st : TStream;
// t1 : TIBOQuery;
// qsl : TIB_StringList;
begin
try
{ the following code is a commented out approach that doesn't
work:
qsl := TIB_StringList.Create;
t1 := TIBOQUERY.Create(Self);
t1.Databasename :=
'APPSERV:F:\IB_DB\IBTHINCLIENT\THINCLIENT.GDB';
t1.IB_Connection := ibconn1;
t1.IB_Transaction := ibt1;
t1.KeyLinks.Append('GRAPHICSTREAM.PKEY');
qsl := TIB_SQLStrings.Create;
qsl.Append('SELECT PKEY, GRAPHIC FROM GRAPHICSTREAM ');
qsl.Append('WHERE GRAPHICNAME = ''' + dbgrid1.Fields[0].AsString
+ '''');
qsl.Append(' AND VERSION = ''' + dbgrid1.Fields[1].AsString +
''';');
t1.SQL.text := qsl.Text; }
// the below listed code is the 'latest attempt' that still doesn't
work
with table1 do
begin
// st := TMemoryStream.Create;
// image.Picture.Graphic.SaveToStream(st);
bf := TBlobField.Create(Self);
bf.Fieldname := 'Graphic';
bf.Name := 'bfGraphic';
bf.Index := 1;
bf.ReadOnly := false;
close;
bf.DataSet := table1;
open;
edit;
insert;
bf.LoadFromFile(edit1.text); // edit1.text contains path
and file
// name info for graphic
FieldByName('graphicname').value :=
extractFileName(edit1.text);
FieldByName('"VERSION"').value := 1;
// := image.Picture.Graphic;
post;
end;
except
on E:EIBO_ISCError do
case E.ERRCODE of
335544665 : begin
messageBeep(0);
messageDlg('You have attempted to '
+'use an existing image '
+'name and version '
+'number. Please choose '
+'a different name for '
+'image.',mtError,
[mbCancel],0);
// t1.Close;
bf.free;
// t1.free;
end;
335544569 : begin
//resolution code here:
// t1.Close;
bf.free;
// t1.free;
showMessage('Ouch!');
end;
end;
end;
// t1.close;
bf.Free;
//t1.free;
end;
[Non-text portions of this message have been removed]