社区
Delphi
帖子详情
我做了个SQL server数据库备份小程序,想做个进度条
limitanger
2005-10-26 10:00:15
我做了个SQL server数据库备份小程序,想做个进度条,因为数据库比较大,备份的时候如果没有进度条提示,就象死机似的
...全文
304
7
打赏
收藏
我做了个SQL server数据库备份小程序,想做个进度条
我做了个SQL server数据库备份小程序,想做个进度条,因为数据库比较大,备份的时候如果没有进度条提示,就象死机似的
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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吧
C#带
进度条
数据库备份
综上所述,"C#带
进度条
数据库备份
"涉及了
数据库备份
策略、C#与
SQL
Server
的交互、UI设计、异步编程、进度跟踪、错误处理等多个方面的技术知识。正确实现这一功能,不仅能够提高备份效率,还能提供更好的用户体验。
数据库备份
还原小工具(源码)
这个名为"
数据库备份
还原小工具(源码)"的项目提供了一个基于WinForm界面的解决方案,它采用C#编程语言实现,可以方便地进行数据库的备份和恢复操作。 在数据库管理中,备份是为了防止数据丢失或损坏,而还原则是...
sql
server
2005 express X64
SQL
Server
2005 Express Edition ...总之,
SQL
Server
2005 Express X64是一个功能强大的数据库解决方案,尤其适合资源有限但又需要高性能处理能力的环境。通过深入学习和实践,您可以充分利用它来满足各种业务需求。
VB
数据库备份
与恢复
通过上述知识点,我们可以构建一个完整的VB应用程序,它能够有效地管理和保护
SQL
Server
数据库,确保在系统故障或数据丢失时能够快速恢复。在实际项目中,还需要考虑性能优化、资源管理以及与其他系统的集成。
sql
安装维护手册
- **操作流程**:启动“维护计划向导”,选择维护任务,例如
数据库备份
、日志清理等,然后设定执行频率。 通过以上详细的操作指南,可以确保
SQL
Server
2008数据库的顺利安装与日常维护工作,提高系统的稳定性和...
Delphi
5,927
社区成员
262,931
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章