类型转换错误,试试这个:<br>uses jpeg;<br>procedure GetImaeg(DataSet: TDataSet);<br>var<br> TempStream: TStringStream;<br> TempJpeg: TJPEGImage;<br>begin<br> try<br> TempStream := nil;<br> TempJpeg := nil;<br> TempStream:=TStringStream.Create('');<br> TempJpeg:=TJPEGImage.Create;<br> try<br> if DataSet.FieldByName('CLTP0').IsNull then Exit;<br><br> TBlobField(DataSet.FieldByName('CLTP0')).SaveToStream(tempstream);<br> TempStream.Position:=0;<br> TempJpeg.LoadFromStream(TempStream);<br> Image1.Picture.Assign(TempJpeg); <br> except<br> on e:exception do<br> begin<br> Application.MessageBox('图片读取失败!','提示',MB_ICONERROR);<br> end;<br> end;<br> finally<br> TempStream.Free;<br> TempJpeg.Free;<br> end;<br>end;<br>//存图片<br>proceudre SaveTODB(DataSet: TADOQuery);<br>var<br> TMStream:TMemoryStream; <br>begin<br> try<br> DataSet.Post;<br> if OpenPictureDialog1.FileName<>'' then<br> begin<br> TMStream:=TMemoryStream.Create;//创建内存流<br> try<br> TMStream.LoadFromFile(OpenPictureDialog1.FileName);//转换OpenPictureDialog1.FileName为内存流,从文件导入<br> DataSet.Close;<br> DataSet.SQL.Clear;<br> DataSet.SQL.Add('update TableName set photo=:ID where id='+#39+trim(edit1.Text)+#39);<br> DataSet.Parameters.ParamByName('ID').LoadFromStream(TMStream,ftTypedBinary);<br> DataSet.ExecSQL;<br> finally<br> TMStream.Free;<br> end;<br> end;<br> showmessage('数据存储成功!');<br> except<br> on e:exception do<br> begin<br> application.MessageBox('数据存储失败!','提示',MB_ICONERROR);<br> end;<br> end;<br>end;