Results 1 to 4 of 4

Thread: MSSQL Backup

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    MSSQL Backup

    Hi

    MySQL is installed on another machine & i am working on remote computer . I want to take MSSQL backup on my computer using VB code

    Thanks

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: MSSQL Backup

    Try:
    Code:
    ' ********************************************************************************
    ' @file        BackRest.bas
    ' @description Backup & Restore with long file names (with spaces)
    ' @copyright   Copyright © SQLDev.Net 1991-2003 All rights reserved.
    ' @author      [email protected]
    ' ********************************************************************************
    
    ' ********************************************************************************
    ' Add reference to Microsoft SQLDMO Object Library
    ' Located in C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.dll
    ' ********************************************************************************
    Private Sub BackupPubs()
        On Error GoTo errHandler
    
        Dim oSQLServer As New SQLDMO.SQLServer
        Dim oBackup As New SQLDMO.Backup
    
        oSQLServer.LoginSecure = True
        oSQLServer.Connect "(local)"
    
        oBackup.Database = "pubs"
        oBackup.Files = "[C:\Program Files\Microsoft SQL Server\80\MSSQL\Backup\pubs.bak]"
        oBackup.SQLBackup oSQLServer
    
        Set oBackup = Nothing
        oSQLServer.DisConnect
        Set oSQLServer = Nothing
    
        Exit Sub 
    
    errHandler:
        Debug.Print Err.Number & " " & Err.Description
    End Sub 
    
    Private Sub RestorePubs()
        On Error GoTo errHandler
    
        Dim oSQLServer As New SQLDMO.SQLServer
        Dim oRestore As New SQLDMO.Restore
    
        oSQLServer.LoginSecure = True
        oSQLServer.Connect "(local)"
    
        oRestore.Database = "pubs"
        oRestore.Files = "[C:\Program Files\Microsoft SQL Server\80\MSSQL\Backup\pubs.bak]"
        oRestore.SQLRestore oSQLServer
    
        Set oRestore = Nothing
        oSQLServer.DisConnect
        Set oSQLServer = Nothing
    
        Exit Sub 
    
    errHandler:
        Debug.Print Err.Number & " " & Err.Description 
    End Sub
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: MSSQL Backup

    errrr
    MySQL is installed on another machine & i am working on remote computer . I want to take MSSQL backup on my computer using VB code
    There's a disconnect there... what does one have to do with the other?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: MSSQL Backup

    Will that code work with MS SQL Express?

    btw - that's got a big-old-nasty copyright in it - @jggtz - is that you in that (c)?

    @jagjit - search the forums for the following and you will see many examples of using T-SQL to backup a MS SQL database.

    szlamany backup

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width