关于SQLDMO.dll~~~~

mdejtod 2006-08-11 08:29:41
怎么我有D里面没有这个东西???想让它创建SQLdmo.pas 可是D里面没有这个ActiveX sqlmdo文件,不知道怎么回事,以前装的D里面都有的~
...全文
237 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
mdejtod 2006-08-12
  • 打赏
  • 举报
回复
真晕~原来我找错地方了~~嘿嘿~
mdejtod 2006-08-12
  • 打赏
  • 举报
回复
谢谢楼上的,试试看~
mdejtod 2006-08-12
  • 打赏
  • 举报
回复
结了,谢谢楼上的,嘿嘿,以后你可就麻烦了~!!
OO_is_just_P 2006-08-11
  • 打赏
  • 举报
回复
跟你老哥学了一招。
OO_is_just_P 2006-08-11
  • 打赏
  • 举报
回复
先选择project,然后Import typelibrary导入Microsoft SQLNamespace Object Library类型库就可以了。
mdejtod 2006-08-11
  • 打赏
  • 举报
回复
晕,SQL都好好的,以前也是一样的,只是在D里面长不到这个东西~~
OO_is_just_P 2006-08-11
  • 打赏
  • 举报
回复
必须先安装SQL Server企业管理器.
1) Choose project, Import typelibrary.
2) Look for "Microsoft SQLNamespace Object Library" in the list.
OO_is_just_P 2006-08-11
  • 打赏
  • 举报
回复
If you have Enterprise manager (SQL Server tools) installed on the machine, you may activate any Enterprise Manager function or menu from within your appliction using SQLNS and SQLDMO.
The good thing is it is easy to make backup as well as restore since it works exactly the same way as using the Enterprise manager. The downside is it will only work if the tools are installed on the client machine.
1) Choose project, Import typelibrary.
2) Look for "Microsoft SQLNamespace Object Library" in the list.
3) Choose install or create unit depending on if you want it as a component or just access using TLB unit as I have.
4) Include SQLNS.pas in uses of your unit.
5) Now do the same 4 steps with "Microsoft SQLDMO Object library" (SQLDMO.pas)
First operation is then to connect to the SQL server...
uses
SQLNS, SQLDMO;
var
FNameSpace:SQLNamespace; // This one needs to be global or part of class as it needs to be accessed by other functions.
var
ConString:OLEVariant;
Hnd:Integer;
FServerName, FPass, FUser: String;
// strings are to be assigned with the password, username and servername to then make part of connection string...
ConString:='Server='+FServerName+';UID='+FUser+';PWD='+FPass+';Trusted_Connection=No';
// The connect operation also requires a window handle. As I had this call within a component I used the one below. If you have a form then Hnd:=Form.Handle instead.
Hnd:=(Owner as TWinControl).Handle;
// Now make the connection...
FNameSpace:= CoSQLNamespace.Create;
FNameSpace.Initialize(FAppName,SQLNSRootType_Server,ConString,Hnd);
// Include the function below to navigate easy in the namespace...
function GetDBNameSpaceObject(
const aDBName: String): SQLNamespaceObject;
var
hServer,hDatabases,hDatabase:Integer;
begin
Result:=nil;
hServer:=FNameSpace.GetRootItem;
hDatabases:=FNameSpace.GetFirstChildItem(hServer,SQLNSOBJECTTYPE_DATABASES,'');
hDatabase:=FNameSpace.GetFirstChildItem(hDatabases,SQLNSOBJECTTYPE_DATABASE,aDBName);
Result:=FNameSpace.GetSQLNameSpaceObject(hDatabase);
end;
// Now you may use this function to activate the "database backup menu" for a particular database on the server...
procedure ShowBackupDB(const aDBName: String);
var
DB:SQLNamespaceObject;
Hnd:Integer;
begin
Hnd:=(Owner as TWinControl).Handle;
DB:=GetDBNameSpaceObject(aDBName);
DB.ExecuteCommandByID(SQLNS_CmdID_DATABASE_BACKUP,Hnd,0);
DB:=nil;
end;
// To show "restore menu", use this procedure...
procedure ShowRestoreDB(const aDBName: String);
var
DB:SQLNamespaceObject;
Hnd:Integer;
begin
Hnd:=(Owner as TWinControl).Handle;
DB:=GetDBNameSpaceObject(aDBName);
DB.ExecuteCommandByID(SQLNS_CmdID_DATABASE_RESTORE,Hnd,0);
DB:=nil;
end;
// To make a backup without showing any interface, use this procedure...
{
RestoreType=SQLDMORestore_Database,
SQLDMORestore_Files,
SQLDMORestore_Log
DeviceName=Valid name of a backup-device
}
procedure RecordBackup(const aDBName: string;
BackupType: SQLDMO_BACKUP_TYPE; const DeviceName: string;
Initialize: Boolean);
var
ThisBackup:_Backup;
begin
try
ThisBackup:=coBackup.Create;
except
Messagedlg('coBackup.Create failed, the object might not be installed on this machine',mtError,[mbOK],0);
end;
ThisBackup.Initialize:=Initialize;
ThisBackup.Database:=aDBName;
ThisBackup.Devices:='['+DeviceName+']';
ThisBackup.SQLBackup(FServer);
ThisBackup:=nil;
end;
// To restore without interface, use this procedure...
procedure TNSConnection.RestoreBackup(const aDBName: string;
RestoreType: SQLDMO_RESTORE_TYPE; const DeviceName: string);
var
ThisRestore:_Restore;
begin
try
ThisRestore:=coRestore.Create;
except
Messagedlg('coRestore.Create failed, the object might not be installed on this machine',mtError,[mbOK],0);
end;
ThisRestore.Database:=aDBName;
ThisRestore.Devices:='['+DeviceName+']';
ThisRestore.Action:=RestoreType;
ThisRestore.SQLRestore(FServer);
end;
OO_is_just_P 2006-08-11
  • 打赏
  • 举报
回复
这个可真没听过。
mdejtod 2006-08-11
  • 打赏
  • 举报
回复
自己顶下~!

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧