How to compress SQL server2000 database backup files, like RAR? Little brother has a 7m of SQL server2000
Database backup files, how to compress in the program AH?
Copy Code code as follows:
Procedure Tform1.button2click (Sender:tobject);
Var
Shexecinfo:shellexecuteinfo;
Begin
Shexecinfo.cbsize: = sizeof (SHELLEXECUTEINFO);
Shexecinfo.fmask: = see_mask_nocloseprocess;
Shexecinfo.wnd: = Handle;
Shexecinfo.lpverb: = nil;
Shexecinfo.lpfile: = ' WinRAR.exe ';
Shexecinfo.lpparameters: = ' a e:\qwqw.rar e:\qwqw ';
Shexecinfo.lpdirectory: = nil;
Shexecinfo.nshow: = Sw_show;
Shexecinfo.hinstapp: = Handle;
ShellExecuteEx (@SHExecInfo);
WaitForSingleObject (shexecinfo.hprocess, INFINITE);
CloseHandle (shexecinfo.hprocess);
ShellExecute (Application. Mainform.handle, ' open ', ' Winrar.exe ', Pchar (' a E:\zqzq.rar e:\zqzq '), ', Sw_show ';
ShowMessage (' Compression complete! '); }
This is a compressed image of the code, the same principle of compressed files, just a little change can be.
Copy Code code as follows:
Var
Mss:tmemorystream;
Zip:tdecompressionstream;
Zip1:tcompressionstream;
Fs:tfilestream;
FBUF:ARRAY[0..16383] of Byte;
Flen:integer;
Remove a picture from the database
//... Write the SQL statement to get a record of the picture, here Conlio
MSS: = Tmemorystream.create;
FS: = Tfilestream.create (' filename.jpg ', fmcreate or fmopenwrite);
Try
Tblobfield (Que.fieldbyname (' pic ')). Savetostream (MSS);
Zip: = tdecompressionstream.create (FS);
Try
Flen: = Zip. Read (Fbuf, SizeOf (FBUF));
While Flen > 0 do begin
Fs. Write (Fbuf, Flen);
Flen: = Zip. Read (Fbuf, SizeOf (FBUF));
End
Finally
Freeandnil (Zip);
End
Finally
Mss. Free;
Fs. Free;
End
To save a picture in a file filename.jpg to a database
//... Write the SQL statement, open the Que, and navigate to the record where you want to save the picture, Conlio
FS: = Tfilestream.create (' filename.jpg ', fmopenread);
MSS: = Tmemorystream.create;
Try
ZIP1: = Tcompressionstream.create (CLDEFAULT,MSS);
Try
Flen: = fs. Read (Fbuf, SizeOf (FBUF));
While Flen > 0 do begin
Zip1. Write (Fbuf, Flen);
Flen: = fs. Read (Fbuf, SizeOf (FBUF));
End
Save to Database
Tblobfield (Que.fieldbyname (' pic ')). Loadfromstream (MSS);
Que.updatebatch ();
//...
Finally
Zip1. Free;
End
Finally
Fs. Free;
Mss. Free;
End