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
Printable View
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
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
errrr
There's a disconnect there... what does one have to do with the other?Quote:
MySQL is installed on another machine & i am working on remote computer . I want to take MSSQL backup on my computer using VB code
-tg
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