F
fusm_2000
Unregistered / Unconfirmed
GUEST, unregistred user!
请问一个SQL语句中一个字段有可能插入图片,也有可能不插入图片怎么办?下面一些代码:
if TImage(RzPanel2.Controls).Picture.Graphic <>NIL then
begin
MyJpeg := TJPEGImage.Create;
try
MyJpeg.Assign(TImage(RzPanel2.Controls).Picture.Graphic);
MS := TMemoryStream.Create;
MyJpeg.SaveToStream(MS);
MS.Position := 0;
qurey1.Close;
qurey1.SQL.Clear;
qurey1.SQL.text:='insert into PrintSetInfo(PrintId,Idtype,mywidth,myheight,'+
'mytop,myleft,fontStyle,labelCaption,image)values('+
QuotedStr(gettypeid)+','+QuotedStr(myidtype)+','+QuotedStr(mywidth)+','+
QuotedStr(myheight)+','+QuotedStr(mytop)+','+QuotedStr(myleft)+',' +
QuotedStr(fontStyle)+','+QuotedStr(labelCaption)+','+
':imagepath' +')' ;
TBlobField(qurey1.Parameters.ParamByName('imagepath')).LoadFromStream(MS);
qurey1.ExecSQL; //这里哪出错了
finally
MyJpeg.Free;
end;
if TImage(RzPanel2.Controls).Picture.Graphic <>NIL then
begin
MyJpeg := TJPEGImage.Create;
try
MyJpeg.Assign(TImage(RzPanel2.Controls).Picture.Graphic);
MS := TMemoryStream.Create;
MyJpeg.SaveToStream(MS);
MS.Position := 0;
qurey1.Close;
qurey1.SQL.Clear;
qurey1.SQL.text:='insert into PrintSetInfo(PrintId,Idtype,mywidth,myheight,'+
'mytop,myleft,fontStyle,labelCaption,image)values('+
QuotedStr(gettypeid)+','+QuotedStr(myidtype)+','+QuotedStr(mywidth)+','+
QuotedStr(myheight)+','+QuotedStr(mytop)+','+QuotedStr(myleft)+',' +
QuotedStr(fontStyle)+','+QuotedStr(labelCaption)+','+
':imagepath' +')' ;
TBlobField(qurey1.Parameters.ParamByName('imagepath')).LoadFromStream(MS);
qurey1.ExecSQL; //这里哪出错了
finally
MyJpeg.Free;
end;