Arsip: Help.....Help..... Access Status 3061

 
user image
more 11 years ago

diko_male

Dear Delphier, Master2... Permisi sebentar ah.... Tumpang tanya sama sesepuh Delphier....... Gw baru main lagi nih delphi.... agak2 lupa.... wkwwk :D. Sebelumnya kalau Repost maaf ya.......Oh iya langsung aja deh.. Gw kan lagi uji coba nih insert picture lewat access, komponen yang gw pake Titan Database..... bukan Ado ya ! Sintaks dibawah kalau gw compile 'success', tapi ketika gw mau save ke DB dia nongolnya begini 'Access Status 3061 - Too Few Parameter - Excepted 1 - Titan (BDE) Error - 2146825227, Begitu katanya, sebelumnya terima kasih ya... procedure TForm1.Button5Click(Sender: TObject); var Gambar : TMemorystream; begin Gambar := TMemorystream.Create; with Form1.taQuery1 do begin close; sql.clear; sql.add('insert into Data (Nama, JenisKelamin, Foto) '+ 'values (:Nama, :JenisKelamin, :Foto) '); Image1.Picture.Graphic.SaveToStream(Gambar); ParamByName('Nama').AsString := Edit1.Text; ParamByName('JenisKelamin').AsString := ComboBox1.Text; ParamByName('Foto').LoadFromStream(Gambar,ftBlob); ExecSQL; end; end; Note : Coding diatas gw edit dari punya 'Eko Indri'
user image
more 11 years ago

diko_male

procedure TForm1.Button5Click(Sender: TObject); var Gambar : TMemorystream; begin Gambar := TMemorystream.Create; with Form1.taQuery1 do begin close; sql.clear; sql.add('insert into Data (Nama, JenisKelamin, Foto) '+ 'values (:Nama, :JenisKelamin, :Foto) '); Image1.Picture.Graphic.SaveToStream(Gambar); ParamByName('Nama').AsString := Edit1.Text; ParamByName('JenisKelamin').AsString := ComboBox1.Text; ParamByName('Foto').LoadFromStream(Gambar,ftBlob); ExecSQL; end; end;
user image
more 11 years ago

madi

coba pake loadfromfile('namafile'). atau disimpan menggunakan TFileStream
user image
more 11 years ago

diko_male

@madi: coba pake loadfromfile('namafile'). atau disimpan menggunakan TFileStream
Aduh ngk bisa boss...... malah tambah error.... kalau bisa minta listing yang lengkap ya............... wkwkwkkwkkw :D
user image
more 11 years ago

madi

cara pertama :

procedure TForm1.Button1Click(Sender: TObject);
var
ms: TMemoryStream;
begin
   if OpenPictureDialog1.Execute then
  begin
    ms := TMemoryStream.Create;
  try
   ms.LoadFromFile(OpenPictureDialog1.FileName);
   with Query1 do
begin
  with SQL do
begin
  Clear;
   Add('INSERT INTO "ImageTbl.db" (ImageFld)');
   Add('VALUES (:param0 )');
end;
  Query1.ParamByName('param0').SetBlobData(ms.Memory, ms.Size);
  ExecSQL;
end;
  finally
  ms.Free;
end;
end;
end;
cara ke dua :

{
  If you develop a database related software, then a very popular task is to
  save some files (documents/images/reports/etc) in some BLOB field of table
  and use these saved data later.
  In this tip I want to show how this task could be solved.
}
// To save a file to BLOB:
procedure TForm1.Button1Click(Sender: TObject);
var
  blob: TBlobStream;
begin
  blob := yourDataset.CreateBlobStream(yourDataset.FieldByName('YOUR_BLOB'), bmWrite);
  try
    blob.Seek(0, soFromBeginning);
    fs := TFileStream.Create('c:\your_name.doc', fmOpenRead or
      fmShareDenyWrite);
    try
      blob.CopyFrom(fs, fs.Size)
    finally
      fs.Free
    end;
  finally
    blob.Free
  end;
end;
  // To load from BLOB:
procedure TForm1.Button1Click(Sender: TObject);
var
  blob: TBlobStream;
begin
  blob := yourDataset.CreateBlobStream(yourDataset.FieldByName('YOUR_BLOB'), bmRead);
  try
    blob.Seek(0, soFromBeginning);
    with TFileStream.Create('c:\your_name.doc', fmCreate) do
      try
        CopyFrom(blob, blob.Size)
      finally
        Free
      end;
  finally
    blob.Free
  end;
end;
{
  Using this code you can work with any database engine (BDE/ADO/DAO/ODBC/etc)
  and any file format (document of MS Word, spreadsheet of MS Excel, bitmap or
  jpeg pictures, wav-files etc)
}
more ...
  • Pages:
  • 1
Share to

Random Topic

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