Arsip: Cara Edit,Hapus,Tampilkan Data berfoto???

 
user image
more 11 years ago

camp_sire

Aku dah bs cara menyimpan data ber-image dlm Access. Tp Aku kesulitan bwt Edit tuh data. Aku pengennya bila ditekan tombol edit tuh data fotonya jg brubah. Trus pas ganti data baru,image sebelumnya kok msh tampil. Gmn biar refresh? Trus jg pas DBGridnya diklik 2x ak pengennya data foto jg ikut tampil. Gmn??? Thnx alot.
procedure TFDataDiri.BBtnSimpanClick(Sender: TObject);
var
  FT       : TMemoryStream;
  IM       : TJPEGImage;
  FL       : String;
begin
  FL := DM.OpenPict1.Files.Strings[0];
  FT := TMemoryStream.Create;
  IM := TJPEGImage.Create;
  IM.LoadFromFile(FL);
  IM.SaveToStream(FT);
  FT.Position := 0;
  .........
 ADOQ1.Active := False;
      ADOQ1.SQL.Clear;
      ADOQ1.SQL.Add('INSERT INTO TDataDiri (Kd_DataDiri, Nama, Umur, Bangsa, '+
                    'Agama, Pekerjaan, Pendidikan, Tempat_Lahir, Tgl_Lahir, Alamat, '+
                    'Blok_Kamar, Foto) VALUES (:a1, :a2, :a3, :a4, :a5, :a6, :a7, '+
                    ':a8, :a9, :a10, :a11, :a12)');
      ADOQ1.Prepared;
      ADOQ1.Parameters[0].Value := EdID.Text;
      ADOQ1.Parameters[1].Value := EdNama.Text;
      ADOQ1.Parameters[2].Value := EdUmur.Text;
      ADOQ1.Parameters[3].Value := Bangsa;
      ADOQ1.Parameters[4].Value := Agama;
      ADOQ1.Parameters[5].Value := EdKerja.Text;
      ADOQ1.Parameters[6].Value := Pendidikan;
      ADOQ1.Parameters[7].Value := Kota;
      ADOQ1.Parameters[8].Value := DateToStr(DTP1.DateTime);
      ADOQ1.Parameters[9].Value := EdAlamat.Text;
      ADOQ1.Parameters[10].Value := EdKamar.Text;
      ADOQ1.Parameters[11].LoadFromStream(FT,ftblob);
      ADOQ1.ExecSQL;
      .....
end;
procedure TFDataDiri.DBGrid1DblClick(Sender: TObject);
begin
  with DM do
  begin
    EdID.Text            := ADOQ1.Fields[0].AsString;
    EdNama.Text          := ADOQ1.Fields[1].AsString;
    EdUmur.Text          := ADOQ1.Fields[2].AsString;
    CbBoxBangsa.Text     := ADOQ1.Fields[3].AsString;
    CbBoxAgama.Text      := ADOQ1.Fields[4].AsString;
    EdKerja.Text         := ADOQ1.Fields[5].AsString;
    CbBoxPendidikan.Text := ADOQ1.Fields[6].AsString;
    CbBoxKota.Text       := ADOQ1.Fields[7].AsString;
    DTP1.DateTime        := ADOQ1.Fields[8].AsDateTime;
    EdAlamat.Text        := ADOQ1.Fields[9].AsString;
    EdKamar.Text         := ADOQ1.Fields[10].AsString;
  end;
end;
user image
more 11 years ago

EkoIndri

barang kali link berikut ini bisa membantu http://ekoindritutorialmenengahdatabase.wordpress.com/access/menyimpan-gambar-kedalam-database-ms-access/
user image
more 11 years ago

camp_sire

Mas EkoIndri ak dah coba, tp kok ttp error? Ak yg g ngerti TADOBlobStream tuh gmn? Oh ya trus wktu Update data apa ttp sama intinya dengan Insert? Mksde ada listing kyk 'ADOQ1.Parameters[11].LoadFromStream(FT,ftblob);' ini?
[Error] UDataDiri.pas(751): Undeclared identifier: 'TADOBlobStream'
[Error] UDataDiri.pas(776): Missing operator or semicolon
[Error] UDataDiri.pas(776): Too many actual parameters
[Error] UDataDiri.pas(777): Missing operator or semicolon
[Error] UDataDiri.pas(777): Left side cannot be assigned to
[Error] UDataDiri.pas(778): Missing operator or semicolon
[Error] UDataDiri.pas(778): Incompatible types: 'TPosition' and 'Integer
procedure TFDataDiri.DBGrid1DblClick(Sender: TObject);
var
  Stream : TADOBlobStream;  //  Error (751)
  GambarJpeg : TJpegImage;
  GambarBmp : TBitmap;
  Buffer : Word;
begin
  with DM do
  begin
    GambarJpeg := TJpegImage.Create;
    GambarBmp := TBitmap.Create;
    RecordBaru := False;
    EdID.Text            := ADOQ6.Parameters[0].Value;
    EdNama.Text          := ADOQ6.Parameters[1].Value;
    EdUmur.Text          := ADOQ6.Parameters[2].Value;
    CbBoxBangsa.Text     := ADOQ6.Parameters[3].Value;
    CbBoxAgama.Text      := ADOQ6.Parameters[4].Value;
    EdKerja.Text         := ADOQ6.Parameters[5].Value;
    CbBoxPendidikan.Text := ADOQ6.Parameters[6].Value;
    CbBoxKota.Text       := ADOQ6.Parameters[7].Value;
    DTP1.DateTime        := ADOQ6.Parameters[8].Value;
    EdAlamat.Text        := ADOQ6.Parameters[9].Value;
    EdKamar.Text         := ADOQ6.Parameters[10].Value;
    ADOQ6.Close;
    ADOQ6.Open;
    Stream := TADOBlobStream.Create(ADOQ6,Foto,bmRead);  //  Error (776)
    Stream.Read(Buffer,SizeOf(Buffer));  //  Error (777)
    Stream.Position := 0;  //  Error (778)
    if Buffer = $D8FF then
    begin
      GambarJpeg.LoadFromStream(Stream);
      DBImage1.Picture.Graphic := GambarJpeg;
    end
    else if Buffer = $4D42 then
    begin
      GambarBmp.LoadFromStream(Stream);
      DBImage1.Picture.Bitmap := GambarBmp;
    end;
  end;
user image
more 11 years ago

EkoIndri

contoh program yang saya berikan waktu mas jalankan di delphi sampeyan error tidak mas?
user image
more 11 years ago

ichan29

dikau coba field fotonya waktu dipanggil di simpan jd stream, baru stream itu panggil ke imagenya, sample:
 Jpg := TJpegImage.Create;
          Ms  := TMemoryStream.Create;
          try
             fieldFotonya.SaveToStream(Ms);
             Ms.Position := 0;
             Jpg.LoadFromStream(Ms);
             cxImage1.Picture.Graphic:= Jpg;
          finally
             Jpg.Free;
             Ms.Free;
          end;
semoga membantu
user image
more 11 years ago

ichan29

walah.. boldnya nga bisa ya klo ditulis dlm code.. sorry, ni tak ulang:
          Jpg := TJpegImage.Create;
          Ms  := TMemoryStream.Create;
          try
             tPhotopic.SaveToStream(Ms);
             Ms.Position := 0;
             Jpg.LoadFromStream(Ms);
             cxImage1.Picture.Graphic:= Jpg;
          finally
             Jpg.Free;
             Ms.Free;
          end;
user image
more 11 years ago

camp_sire

Oh iya ada error wktu ak tekan ctrl-F9 pas abis buat parameter d data module-nya. Apa yg slh?
user image
more 11 years ago

muktaf


  procedure InsertImageToDB(param: AnsiString);
  var
    ms: TMemoryStream;
  begin
    ms := TMemoryStream.Create;
    try
      ms.LoadFromFile(OpenPictureDialog.FileName);
      with DMProject.ZQuery do
      begin
        Close;
        SQL.Clear;
        SQL.Add(param);
        ParamByName('paramBLOB').SetBlobData(ms.Memory, ms.Size);
        ExecSQL;
      end;
    finally
      ms.Free;
    end;
  end;
untuk load db

  procedure LoadImageFromDB;
  var
    Strm: TMemoryStream;
    JPEGImage: TJPEGImage;
    Photo: TBlobField;
  begin
    Strm:=TMemoryStream.Create;
    JPEGImage:=TJPEGImage.Create;
    try
      Photo:= ZQuery.FieldByName('Company_logo') as TBlobField;
      Photo.SaveToStream(Strm);
      Strm.Seek(0, soFromBeginning);
      JPEGImage.LoadFromStream(Strm);
      ImageCompany_logo.Picture.Assign(JPEGImage);
    finally
      Strm.Free;
      JPEGImage.Free;
    end;
  end;
semoga membantu ... Terimakasih by ImanD
user image
more 11 years ago

muktaf

tambah lagi pake type memo aja untuk di ado biar nampung blob...
more ...
  • Pages:
  • 1
Share to

Random Topic

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