可以直接使用ADO的Connection对象执行下面的SQL
只需要把相关的换成你的数据库文件和你的备份文件
参见MS Transact-SQL Help
-- Create the backup device for the full MyNwind backup.
USE master
EXEC sp_addumpdevice 'disk', 'MyNwind_2',
'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwind_2.dat'--Create the log backup device.
USE master
EXEC sp_addumpdevice 'disk', 'MyNwindLog1',
'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwindLog1.dat'-- Back up the full MyNwind database.
BACKUP DATABASE MyNwind TO MyNwind_2-- Update activity has occurred since the full database backup.-- Back up the log of the MyNwind database.
BACKUP LOG MyNwind
TO MyNwindLog1
只需要把相关的换成你的数据库文件和你的备份文件
参见MS Transact-SQL Help
-- Create the backup device for the full MyNwind backup.
USE master
EXEC sp_addumpdevice 'disk', 'MyNwind_2',
'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwind_2.dat'--Create the log backup device.
USE master
EXEC sp_addumpdevice 'disk', 'MyNwindLog1',
'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwindLog1.dat'-- Back up the full MyNwind database.
BACKUP DATABASE MyNwind TO MyNwind_2-- Update activity has occurred since the full database backup.-- Back up the log of the MyNwind database.
BACKUP LOG MyNwind
TO MyNwindLog1
太简单了,请在详细点。最好用VB代码。帮帮忙!!
如何调用存储过程??
太简单了,请在详细点。最好用VB代码。帮帮忙!!
如何调用存储过程??
然后使用Connection.Excute方法一句句的执行即可
最好在前面最好用Recordset对象接收一下sp_who命令查询一下当前有没有其他用户访问
该数据库
set rs=cn.excute("sp_who")
[email protected]
[email protected]
021-65710016
[email protected]
[email protected]
021-65710016
以上功能我已成功,
但如何Restore呢??
1. Backup database:
' Create a Backup object and set action and source database properties.
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Database
oBackup.Database = "Northwind"' Example illustrates a striped backup using two target devices. Note:
' Device creation is not illustrated in this example.
oBackup.Devices = "[NorthDev1],[NorthDev2]"' Optional. Backup set name and description properties provide
' descriptive text when backup header is displayed for the device(s).
oBackup.BackupSetName = "Northwind_Full"
oBackup.BackupSetDescription = "Full backup of Northwind sample."' Call SQLBackup method to perform the backup. In a production
' environment, consider wrapping the method call with a wait pointer
' or use Backup object events to provide feedback to the user.
'
' Note: Create and connect of SQLServer object used is not
' illustrated in this example.
oBackup.SQLBackup oSQLServer2. Restore Database
' Create a Restore object and set action and target database properties.
Dim oRestore As New SQLDMO.Restore
oRestore.Action = SQLDMORestore_Database
oRestore.Database = "Northwind"' Example illustrates restore from a striped backup. Two source devices
' are specified. The full database backup is indicated as the first
' backup set by using the FileNumber property. Note: Device creation is
' not illustrated in this example.
oRestore.Devices = "[NorthDev1],[NorthDev2]"
oRestore.FileNumber = 1' Optional. ReplaceDatabase property ensures that any existing copy
' of the database is overwritten.
oRestore.ReplaceDatabase = True' Call SQLRestore method to perform the restore. In a production
' environment, consider wrapping the method call with a wait pointer
' or use Restore object events to provide feedback to the user.
'
' Note: Create and connect of SQLServer object used is not
' illustrated in this example.
oRestore.SQLRestore oSQLServer