社区
Delphi
帖子详情
我做了个SQL server数据库备份小程序,想做个进度条
limitanger
2005-10-26 10:00:15
我做了个SQL server数据库备份小程序,想做个进度条,因为数据库比较大,备份的时候如果没有进度条提示,就象死机似的
...全文
326
7
打赏
收藏
我做了个SQL server数据库备份小程序,想做个进度条
我做了个SQL server数据库备份小程序,想做个进度条,因为数据库比较大,备份的时候如果没有进度条提示,就象死机似的
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
xjp_1999
2006-04-03
打赏
举报
回复
收藏
不若人生一场醉
2005-10-26
打赏
举报
回复
to oushengfen(逸帆) ( ) 信誉:88
收了
superyys
2005-10-26
打赏
举报
回复
楼上的是好东东,收藏
oushengfen
2005-10-26
打赏
举报
回复
用SQLDMO对象来做是可以的。
在http://dev.csdn.net/article/67303.shtm中有关于SQLDMO的导入;
有一个DELPHI下的SQL备份控件,能显示备份的百分数,也就可以做进度条。
unit SQLBackup;
interface
uses
Windows, Messages, SysUtils, Classes,SQLDMO_TLB,SQLDMO_Command,ActiveX,ComObj,Forms;
type
TPercentCompleteEvent=procedure(Message: String;Percent:Integer) of object;
TMessageEvent=procedure(Message:String) of object;
TBackupMode= (FullDatabase, Differential);
TSQLBackup = class(TComponent)
private
FServerName: String; //数据库服务器名称
FdatabaseName:String; //数据库名称
FLoginTimeout:Integer;//登陆延时
FBackupMode:TBackupMode;//备份数据模式
FOnPercentComplete: TPercentCompleteEvent;
FOnNextMedia: TMessageEvent;
FOnComplete: TMessageEvent;
oSQLServer:_SQLServer;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent);
destructor Destroy;override;
procedure Connect(UserName:String;Password:String); overload;
procedure Disconnect;
procedure SQLBackup (FileName:String);
property ServerName:String read FServerName write FServerName;
property DataBaseName:String read FdataBaseName write FDatabaseName;
property LoginTimeout:Integer read FLoginTimeout write FLoginTimeout default 30;
property BackupMode:TBackupMode read FBackupMode write FBackupMode;
property PercentComplete:TPercentCompleteEvent read FOnPercentComplete write FOnPercentComplete;
property NextMedia:TMessageEvent read FOnNextMedia write FOnNextMedia;
property Complete:TMessageEvent read FOnComplete write FOnComplete;
published
{ Published declarations }
end;
TBackupSink=class (TInterfacedObject,BackupSink)
private
function PercentComplete(const Message: WideString; Percent: Integer): HResult; stdcall;
function NextMedia(const Message: WideString): HResult; stdcall;
function Complete(const Message: WideString): HResult; stdcall;
public
SQLBackup: TSQLBackup;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TSQLBackup]);
end;
{ TSQLBackup }
procedure TSQLBackup.Connect(UserName, Password: String);
begin
try
osqlServer.LoginSecure :=False;
osqlServer.LoginTimeout :=FLoginTimeout;
osqlServer.Connect(FServerName,userName,Password);
except
Raise;
end;
end;
constructor TSQLBackup.Create(AOwner: TComponent);
begin
try
inherited create(AOwner);
osqlServer :=coSqlServer.Create;
oSqlServer._AddRef;
except
Raise;
end;
end;
destructor TSQLBackup.Destroy;
begin
OSqlServer._Release;
osqlServer :=nil;
inherited Destroy;
end;
procedure TSQLBackup.Disconnect;
begin
try
osqlServer.DisConnect;
except
Raise;
end;
end;
procedure TSQLBackup.SQLBackup(FileName: String);
var
obackup :_backUp;
oBackupSink :TBackupSink;
ConnectionPoint:IConnectionPoint;
dwCookie:Integer;
ConnectionPointContainer :IConnectionPointContainer;
begin
try
obackup := cobackup.Create;
obackup._AddRef;
obackup.Database :=FDataBaseName;
if FBackupMode=FullDatabase then
obackup.Action :=SQLDMOBackup_Database
else
obackup.Action :=SQLDMOBackup_Differential;
obackup.Files :=FileName;
oBackupSink :=TBackupSink.Create;
oBackupSink._AddRef;
obackupsink.SQLBackup :=self;
obackup.QueryInterface(IConnectionPointContainer,ConnectionPointContainer);
ConnectionPointContainer._AddRef;
ConnectionPointContainer.FindConnectionPoint(BackupSink,ConnectionPoint);
ConnectionPoint._AddRef;
ConnectionPoint.Advise(oBackupSink,dwCookie);
application.ProcessMessages;
obackup.SQLBackup(oSqlServer);
ConnectionPoint.Unadvise(dwCookie);
obackup._Release;
obackup :=nil;
oBackupSink._Release;
oBackupSink :=nil;
ConnectionPoint._Release;
ConnectionPoint :=nil;
ConnectionPointContainer._Release;
ConnectionPointContainer :=nil;
application.ProcessMessages;
except
Raise;
end;
end;
{ TBackupSink }
function TBackupSink.Complete(const Message: WideString): HResult;
begin
try
SQLBackup.Complete(message);
except
Raise;
end;
end;
function TBackupSink.NextMedia(const Message: WideString): HResult;
begin
try
SQLBackup.NextMedia(message);
except
Raise;
end;
end;
function TBackupSink.PercentComplete(const Message: WideString;
Percent: Integer): HResult;
begin
try
SQLBackup.PercentComplete(message,Percent);
except
Raise;
end;
end;
end.
aiirii
2005-10-26
打赏
举报
回复
有个sql server 的 COM 组件,可以实现回调,但在delphi试验不出, 用vb, c#就可, 奇怪
yanlls
2005-10-26
打赏
举报
回复
估计只能作个假的
9807146wang
2005-10-26
打赏
举报
回复
用进度条控件就可以了,然后设置step=1,还有spID吧
【开题答辩全过程】以 儿童疫苗接种信息管理系统为例,包含答辩的问题和答案
本文以《基于Web的儿童疫苗接种信息管理系统》为案例,详细记录了开题答辩全过程,涵盖系统架构、功能设计、数据库方案及常见问题应对。系统采用ASP.NET +
SQL
Server
技术栈,实现家长端自助服务与管理端高效运维,具备高可用性与安全性,适合基层医疗应用场景。
WordPress故障排查前必须
做
的7步系统性优化
本文提出WordPress故障排查前必须执行的7步系统性优化流程,涵盖环境健康度扫描、核心与环境兼容性校验、数据库精简与索引优化、PHP及Web服务器配置调优、静态资源与缓存策略重构、插件与主题轻量化审计、监控与基线建立。该流程可将90%日常问题的平均排障时间从3小时压缩至20分钟内,强调优化是高效排障的必要前置条件,而非可选补充。
PHPCMS附件上传功能升级包:用原生HTML5替代Flash,适配Chrome/Edge等新浏览器
PHPCMS V9默认依赖Flash的附件上传组件在Chrome 88+、Edge 90+、Firefox 85+等现代浏览器中完全失效,点击无响应或报JS错误,根源是浏览器全面移除Flash插件支持。这个升级包提供开箱即用的HTML5上传方案,直接替换phpcms/modules/attachment、statics/js/目录下对应文件,不改动数据库结构、不调整后台设置、不重写权限逻辑。支持图片(JPG/PNG/GIF)、文档(PDF/DOC/XLS)、压缩包(ZIP/RAR)等常见类型,保留原有文件大
Django 4.2 对象存储实战:S3 兼容配置与安全迁移指南
本文详解Django 4.2对接S3兼容对象存储(如阿里云OSS、腾讯云COS)的生产级配置方案,涵盖django-storages选型依据、安全密钥三重防护(环境变量隔离、最小权限策略、STS临时凭证)、Settings核心参数计算逻辑、ImageField零代码迁移、Admin与前端直传适配,以及多环境隔离、病毒扫描集成和成本监控告警等进阶实践。
产业园区运营负责人如何利用产业大脑实现企业精准招商?.docx
科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。
Delphi
5,943
社区成员
262,943
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章