Arsip: Load image dari SQL SERVER

 
user image
more 12 years ago

rebeltwisted

Teman2 semua... aq masih baru d dunia delphi... aq ingin nanya bagaimana caranya load image dari SQL server, dari field yang bertipe image (binary). trus hasilnya ditampilka di TImage delphi.... aq uda coba begini... procedure TFormlatihlvq.DBGrid1CellClick(Column: TColumn); var p: TADOBlobStream; oJpeg : TJPEGImage; oADOImage : TBlobField; str:TStream; begin oJpeg := TJPEGImage.Create; oADOImage := TBlobField.Create(self); Form1.ADOQuery1.Close; Form1.ADOQuery1.SQL.Clear; Form1.ADOQuery1.SQL.Add('select * from tb_gambar where id=2'); //Query2.ParamByName('nomor').AsInteger :=SpinEdit2.Value; with oADOImage do begin TBlobField(Form1.ADOQuery1.FieldByName('gambar')).SaveToStream(str); end; Form1.ADOQuery1.Open; Form1.ADOQuery1.ExecSQL; p := TADOBlobStream.Create(oADOImage,bmRead); If p.Size <> 0 then begin oJpeg.LoadFromStream(p); Imageprev.Picture.Assign(oJpeg); end; //clean up p.Free; oJpeg.Free; oADOImage.Free; end; Tapi hasilnya tidak berhasil... dikatakan tidak ditemukan adoquery1 field gambar..... padahal struktur tb_gambar (id,gambar).... mohon pencerahannya saudaraku.... thx's
user image
more 12 years ago

rebeltwisted

setelah dirubah... procedure TFormlatihlvq.DBGrid1CellClick(Column: TColumn); var p: TADOBlobStream; oJpeg : TJPEGImage; oADOImage : TBlobField; str:TStream; begin oJpeg := TJPEGImage.Create; oADOImage := TBlobField.Create(self); Form1.ADOQuery1.Close; Form1.ADOQuery1.SQL.Clear; Form1.ADOQuery1.SQL.Add('select gambar from tb_gambar where id=2'); Form1.ADOQuery1.Open; Form1.ADOQuery1.ExecSQL; //Query2.ParamByName('nomor').AsInteger :=SpinEdit2.Value; oJpeg.Assign(Form1.ADOQuery1.FieldByName('gambar')); Imageprev.Picture.Assign(oJpeg); //clean up oJpeg.Free; end; hasilnya jpeg error 53
user image
more 12 years ago

madi

coba pake Tbitmap
user image
more 12 years ago

rebeltwisted

udah coba pake TBitmap kaya gini... procedure TFormlatihlvq.DBGrid1CellClick(Column: TColumn); var str:TMemoryStream; begin Form1.ADOQuery1.Close; Form1.ADOQuery1.SQL.Clear; Form1.ADOQuery1.SQL.Add('select gambar from tb_gambar where id=2'); Form1.ADOQuery1.Active:=true; Form1.ADOQuery1.ExecSQL; //Query2.ParamByName('nomor').AsInteger :=SpinEdit2.Value; TBlobField(Form1.ADOQuery1.FieldByName('gambar')).SaveToStream(str); Imageprev.Picture.Bitmap.LoadFromStream(str); //Imageprev.Picture.Assign(jpg); str.Free; end; Hasilnya stream write error.... tolong bantuannya dong.... isi type image di db yang ingin di load k image delphi seperti berikut 0x424D961500000000000036000000280000001F0000003900000001001800000000006015000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
user image
more 12 years ago

madi

mending pake TDBImage saja buat nampilinnya...:D
user image
more 12 years ago

rebeltwisted

udah berhasil...... :D :D :D :D Thank's.... bos madi
user image
more 12 years ago

madi

Hehehe...jangan lupa ya "ROYALTINYA" :lol: :lol: :wink: :mrgreen:
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com