Home > Back-end >  Access OLE object in the read and write operations
Access OLE object in the read and write operations

Time:09-26

3. 1 in the Access BLOB data library. MDB, Graphic, structure such as below:

BLOB figure number according to the library. The NLDB Gra phic table structure.
3. 2 design interface
Form component placement ADOConnection1, ADOQueryl Imagel, Data Surce1, DBNavigator1. Two o Tradio Button,
Call points don't RBTN BMP, RBTN JG. Set P set ADOConnectionl Connection Sring even t pick up to a few BLOB, according to the library. The MDB. A buy
ADOQue ~ I Connection for ADOConnectionl, SQL to Select the from Graphic; Set Set Data Surcel o Data Set for
ADOQue ~ I, set DBNavigatorl Data Surce for o Data Source1.



do you look at the code where I write wrong,,,,,,,


The unit Unit1;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ExtCtrls DBCtrls, DB, the ADODB library;

Type
TForm1=class (TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Image1: TImage;
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
RbtnBMP: TRadioButton;
RbtnJPG: TRadioButton;
Procedure FormCreate (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}


Uses JPEG
Procedure TForml. FormCreate (Sender; TObject);
The begin
ADOConnection1. The ConnectionString:=
The Provider=Microsoft. Jet. The OLEDB. 4.0; The Data source=BLOB. Accdb ';
ADOConnection1. Connected:=True;
ADOQuery1. Open;
end;
{to Access database save BMP, JPG image process}
Procedure TForml. SaveP. MpJpg;
The begin
With TOpenDialog. Create (Self) to do
The begin
Filter: BMP=(*. BMP)/*. BMP/JPG (*.jpg)/*. JPG ';
If the Execute then
The begin
AdoQuery1. First;
If FilterIndex=1 then
The begin
While AdoQuery1bmp. BlobSize<> 0 do begin
AdoQuery1. Next;
If AdoQuery1. Eof then AdoQuery1. Append;
end;
AdoQuery1. Edit;
TBlobField (AdoQuery1 FieldByName (BMP)) LoadFromFile
(FileName);
end;
If FilterIndex=2 then
The begin
While AdoQuery1 jpeg. BlobSize<> 0 do begin
AdoQuery1. Next;
If AdoQuery1 jpeg. Eof then AdoQuery1. Append;

end;
AdoQuery1. Edit;
TBlobField (AdoQuery1 FieldByName (jpeg ')). Loadfrom -
The File (FileName);
end;
AdoQuery1. Post;
end;
end;
end;
{display BMP images process}
Procedure TForml. DisplayBMP;
Var: ms TMemoryStream;
The begin
If AdoQuery1bmp. BlobSize> 0 then
The begin
Ms:=Tmemorystream. Create;
TBlobField (AdoQuery1 FieldByName (BMP)) SaveToStream (ms).
Ms. Seek (0, soFromBeginning);
Image1. Picture. Bitmap. LoadFromStream (Ms).

Ms. The Free;
End
The else
Image1. Picture:=nil;
end;
{display JPG images process}
Procedure TForml. DisplayJPG;
Var
Jpeg: Tjpegimage; Ms: TMemoryStream;
The begin
If AdoQuery1 jpeg. BlobSize> 0 then
The begin
Jpeg:=Tjpegimage. Create;
Ms:=Tmemorystream. Create;
TBlobField (adoquery1 FieldByName (' jpeg '))
SaveToStream (ms).
Ms. Seak (0, soFromBeginning);
Jpeg. LoadFromStream (ms);
Image1. Picture. Assign (jpeg);
Jpeg. Free;
Ms. The Free;
End
The else
Image1. Picture:=nil;
end;

CodePudding user response:

Everyone a great god for revision guide
  • Related