Code to compress SQL server2000 database backup files in a program _mssql

Source: Internet
Author: User
Tags rar zip
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.