unit Unit
interface
uses
Windows
ExtCtrls
{一定要USES JPEG單元
type
TForm
DataSource
ADOQuery
DBGrid
DBNavigator
Image
savebutton: TButton;
showbutton: TButton;
OpenDialog
ADOQuery
ADOQuery
procedure savebuttonClick(Sender: TObject);
procedure showbuttonClick(Sender: TObject);
procedure DBNavigator
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form
implementation
{$R *
function JpegStartsInBlob(PicField:TBlobField):integer;
var
ghy: TADOBlobstream;
buffer:Word;
hx: string;
begin
Result :=
ghy := TADOBlobstream
try
while (Result =
begin
ghy
hx:=IntToHex(buffer
if hx =
ghy
hx:=IntToHex(buffer
if hx =
else if hx =
ghy
end; //if
end; //while
finally
ghy
end; //try
end;
procedure TForm
var
picstream:tadoblobstream;
begin
adoquery
picstream:=tadoblobstream
if form
begin
picstream
picstream
adoquery
tblobfield(adoquery
adoquery
end;
end;
procedure TForm
var
ghy:TADOBlobstream;
pic:tjpegimage;
begin
ghy := TADOBlobstream
try
ghy
Pic:=TJpegImage
try
Pic
Image
finally
Pic
end;
finally
ghy
end;
end;
procedure TForm
begin
if button in [nbFirst
end;
end
如果數據庫中要存儲的是BMP文件
procedure TForm
var
ghy:TADOBlobstream;
pic:tbitmap;
begin
ghy := TADOBlobstream
try
{ ghy
Pic:=Tbitmap
try
Pic
Image
finally
Pic
end;
finally
ghy
end;
end;
到此用DELPHI存取JPEG文件到SQL Server數據庫中的具體操作已經敘述完畢
From:http://tw.wingwit.com/Article/program/Delphi/201311/24961.html