VB做程序时如何对SQL SERVER 数据库进行备份?   实战用过的方法.

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2854/2854264.xml?temp=.705044此帖裡面方法有效
      

  2.   

    建議樓主搜索一下,yoki的程序都能過,很強悍的人呢
      

  3.   

    我最近也遇到了同样的情况,通过以下方法解决了。
    建议先建一个excel或者acess表,然后将数据库内容导出到所建的表中。
    最后再将把表的内容导入就可以了。推荐用excel,因为这个对所建的表的字符类型没有什么限制,而acess可能对都是char类型的比较好,但其它的类型有时候无法全部导入
      

  4.   

    '备份:    Me.MousePointer = 11
        strDate = Format(Now, "yyyymmddHhNnSs")
        strSQL = "BACKUP database " & DatabaseName & " TO DISK='" _
                & strPath & DatabaseName & strDate & ".bak'" _
                & " WITH RESTART"
        strServer = GetINI(gstrCurrPath & DSNINIFile, "Database", "Server", "?")
        If strServer = "?" Then
            Me.MousePointer = 0
            MsgBox "服务器信息已被损坏,程序将用缺省值进行修复!", vbExclamation, "提示"
            strServer = "(local)"
            Me.MousePointer = 11
        End If
        
        CloseRS
        Set con = New ADODB.Connection
        con.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Server=" & strServer
        con.Open
        con.Execute strSQL
        Me.MousePointer = 0
      

  5.   

    '恢复:    Me.MousePointer = 11
        
        strSQLRestore = "RESTORE DATABASE " & DatabaseName & " FROM DISK = '" _
                & strPath & File1.FileName _
                & "' with" _
                & " MOVE '" & DatabaseName & "_data' TO '" _
                & gstrCurrPath & DatabaseDir & DatabaseName & "_data.mdf'" _
                & ",MOVE '" & DatabaseName & "_log' TO '" _
                & gstrCurrPath & DatabaseDir & DatabaseName & "_log.ldf'" _
                & ",replace,restart"
        
        If Dir(strPath & DatabaseName & "_data.MDF", vbNormal) <> "" Then
            Kill strPath & DatabaseName & "_data.MDF"
        End If
        
        strServer = GetINI(gstrCurrPath & DSNINIFile, "Database", "Server", "?")
        If strServer = "?" Then
            Me.MousePointer = 0
            MsgBox "服务器信息已被损坏,程序将用缺省值进行恢复!", vbExclamation, "提示"
            strServer = "(local)"
            Me.MousePointer = 11
        End If
        
        CloseRS
    '    GCon.Close
        Set GCon = Nothing
        
        Set con = New ADODB.Connection
        con.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Server=" & strServer
        con.Open
        con.Execute strSQLRestore
        con.Close
        Set con = Nothing
        
        ConnectDatabase GCon
         
        Me.MousePointer = 0
        MsgBox "数据库恢复成功!", vbInformation, "祝贺"
      

  6.   

    To  kissoflife(明月高楼休独倚,酒入愁肠,化作相思泪!) :
    请问如果是oracle数据库改如何操作?
      

  7.   

    http://expert.csdn.net/Expert/topic/2854/2854264.xml?temp=.705044