Arsip: Insert/Update image into DB via SQL-Command


by LuriDarmawan in Database more 14 years ago 3307
Sering kali pertanyaan ini muncul, bagaimana cara memasukkan image ke dalam DB melalu perintah SQL ?
Contoh berikut semoga bisa membantu.

/////////////////////
Screen.Cursor :=crHourGlass;
ADOConnection.BeginTrans;
try
with ADOQuery do
begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO PHOTO_FILE ');
SQL.Add('(PHOTO_CODE ,');
SQL.Add(' PHOTO_IMAGE )');
SQL.Add('VALUES ');
SQL.Add('('+#39+txtCode.Text+#39+',');
SQL.Add(' '+':PHOTO'+')');
if Photo.Picture.Graphic <> nil then
Parameters.ParamByName('PHOTO').Assign(Photo.Picture.Graphic)
else Parameters.ParamByName('PHOTO').Value :=NULL;
ExecSQL;
end;
ADOConnection.CommitTrans;
Screen.Cursor :=crDefault;
except
on E:Exception do
begin
Screen.Cursor :=crDefault;
ShowMessage(E.Message);
ADOConnection.RollbackTrans;
end;
end;
//////////////////
Syntax Highlighted with https://pascal-id.org/syntax



SEMANGAT!
ref: http://www.delphi3000.com/articles/article_4579.asp?SK=
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com