备份:
backup database database_name to disk='you_path';
恢复
restore database database_name from disk='you_path'
恢复时,要完全断开连接。
一定要给分啊。

解决方案 »

  1.   

    SQL Server可以使用SQL-DMO来做:
    sql server有个dll是sqldmo.dll可以调用
    恢复数据库:
    Private Sub Command2_Click()
        Dim sFile As String
        sFile = "N_1"
      
        Dim oServer As New SQLDMO.SQLServer
        Dim oDatabase As New SQLDMO.Database
        Dim oRestore As New SQLDMO.Restore
        
        oServer.Connect servername, username, password
        With oRestore
        
            .Files = sFile
            
            .Database = "Northwind"
            .ReplaceDatabase = True
            .SQLRestore oServer
        End With
        
        Set oRestore = Nothing
        Set oDatabase = Nothing
        oServer.DisConnect
        Set oServer = Nothing
        MsgBox ("OK")
        
    End Sub备份:
    Dim oBackup As New SQLDMO.Backup
    oBackup.Action = SQLDMOBackup_Database
    oBackup.Database = "Northwind"
    oBackup.Devices = "[NorthDev1],[NorthDev2]"
    oBackup.BackupSetName = "Northwind_Full"
    oBackup.BackupSetDescription = "Full backup of Northwind sample."oBackup.SQLBackup oSQLServer
    如果你按照上述方法做好一个通用的过程把原代码给我看看!!
    我也是抄来的我不懂vb,
    [email protected][email protected]