PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average.

Backup of Remote SQL Server using VB Net Code

 
 
MikeTI
Guest
Posts: n/a
 
      26th Jan 2010
Jan 26, 2010

Hi all

I am using VB Net 2008 and SQL 2008.

I am taking a backup of a local SQL Server Database using the following
code:

Dim backup As SQLDMO.Backup = New SQLDMO.BackupClass()
Dim sqlserver As SQLDMO.SQLServer = New SQLDMO.SQLServerClass()
sqlserver.LoginSecure = False
sqlserver.Connect("MIKETI-PC\sqlexpress", "sa", "sapassword")
backup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database
backup.Database = "TestDataBase"

backup.Files = "C:\SQL_BACKUP\TestDataBase.bak"
backup.BackupSetName = "Test01"
backup.BackupSetDescription = "Database backup description"
backup.Initialize = True
backup.SQLBackup(sqlserver)

How can I take a backup of a remote SQL Server Database on my local PC ??

Regards
Mike TI



 
Reply With Quote
 
 
 
 
Joe Cool
Guest
Posts: n/a
 
      26th Jan 2010
On Jan 26, 6:21*am, "MikeTI" <(E-Mail Removed)> wrote:
> Jan 26, 2010
>
> Hi all
>
> I am using VB Net 2008 and SQL 2008.
>
> I am taking a backup of a local SQL Server Database using the following
> code:
>
> * * * * Dim backup As SQLDMO.Backup = New SQLDMO.BackupClass()
> * * * * Dim sqlserver As SQLDMO.SQLServer = New SQLDMO.SQLServerClass()
> * * * * sqlserver.LoginSecure = False
> * * * * sqlserver.Connect("MIKETI-PC\sqlexpress", "sa", "sapassword")
> * * * * backup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database
> * * * * backup.Database = "TestDataBase"
>
> * * * * backup.Files = "C:\SQL_BACKUP\TestDataBase.bak"
> * * * * backup.BackupSetName = "Test01"
> * * * * backup.BackupSetDescription = "Database backup description"
> * * * * backup.Initialize = True
> * * * * backup.SQLBackup(sqlserver)
>
> How can I take a backup of a remote SQL Server Database on my local PC ??
>


Use a standard SqlClient connection and execute a backup database
transact-sql command. It is my impression that you will only be able
to make a backup copy to a local disk, but you can make a backup to
network disk if SQL instance service is running under a domain/
workgroup account instead of the server's local SYSTEM account.

http://msdn.microsoft.com/en-us/library/ms186865.aspx
 
Reply With Quote
 
 
 
 
Rich P
Guest
Posts: n/a
 
      26th Jan 2010
If you are working remotely, I think you can only run the backup
operation on the machine (the remote server) where the DB resides. Then
you can copy/FTP the .bak to your local computer. I think.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
eliza
Guest
Posts: n/a
 
      17th Mar 2010
Using the SQL SMO object we can easily take backup of SQL database through code.To find the codes plz check th link below:

http://www.mindfiresolutions.com/Bac...-VBNET-846.php



MikeTI wrote:

Backup of Remote SQL Server using VB Net Code
26-Jan-10

Jan 26, 201

Hi al

I am using VB Net 2008 and SQL 2008

I am taking a backup of a local SQL Server Database using the followin
code

Dim backup As SQLDMO.Backup = New SQLDMO.BackupClass(
Dim sqlserver As SQLDMO.SQLServer = New SQLDMO.SQLServerClass(
sqlserver.LoginSecure = Fals
sqlserver.Connect("MIKETI-PC\sqlexpress", "sa", "sapassword"
backup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Databas
backup.Database = "TestDataBase

backup.Files = "C:\SQL_BACKUP\TestDataBase.bak
backup.BackupSetName = "Test01
backup.BackupSetDescription = "Database backup description
backup.Initialize = Tru
backup.SQLBackup(sqlserver

How can I take a backup of a remote SQL Server Database on my local PC ?

Regard
Mike TI

Previous Posts In This Thread:

On Tuesday, January 26, 2010 6:21 AM
MikeTI wrote:

Backup of Remote SQL Server using VB Net Code
Jan 26, 201

Hi al

I am using VB Net 2008 and SQL 2008

I am taking a backup of a local SQL Server Database using the followin
code

Dim backup As SQLDMO.Backup = New SQLDMO.BackupClass(
Dim sqlserver As SQLDMO.SQLServer = New SQLDMO.SQLServerClass(
sqlserver.LoginSecure = Fals
sqlserver.Connect("MIKETI-PC\sqlexpress", "sa", "sapassword"
backup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Databas
backup.Database = "TestDataBase

backup.Files = "C:\SQL_BACKUP\TestDataBase.bak
backup.BackupSetName = "Test01
backup.BackupSetDescription = "Database backup description
backup.Initialize = Tru
backup.SQLBackup(sqlserver

How can I take a backup of a remote SQL Server Database on my local PC ?

Regard
Mike TI

On Tuesday, January 26, 2010 12:14 PM
Joe Cool wrote:

rClass()rd")Databaseion"Use a standard SqlClient connection and execute a
rClass(
rd"
Databas
ion

Use a standard SqlClient connection and execute a backup databas
transact-sql command. It is my impression that you will only be abl
to make a backup copy to a local disk, but you can make a backup t
network disk if SQL instance service is running under a domain
workgroup account instead of the server's local SYSTEM account

http://msdn.microsoft.com/en-us/library/ms186865.aspx

On Tuesday, January 26, 2010 3:11 PM
Rich P wrote:

If you are working remotely, I think you can only run the backupoperation on
If you are working remotely, I think you can only run the backu
operation on the machine (the remote server) where the DB resides. The
you can copy/FTP the .bak to your local computer. I think

Ric

*** Sent via Developersdex http://www.developersdex.com ***


Submitted via EggHeadCafe - Software Developer Portal of Choice
Get Started with SQLite and Visual Studio
http://www.eggheadcafe.com/tutorials...-sqlite-a.aspx
 
Reply With Quote
 
New Member
Join Date: Sep 2012
Posts: 2
 
      22nd Sep 2012
Hey sir

hmmm use this

'--imports the tools

Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common
'--here you are Declare the object of backup

Dim WithEvents oBackup As New Backup



Private Sub BackupSqlDatabase()
Dim conn As New ServerConnection(serverName, userName, passWd) ' -- set SQL server connection given the server name, user name and password
Dim oSQLServer As New Server(conn)
'--create the SMO server object using connection
Dim OrigBackupPath As String = oSQLServer.Information.MasterDBPath.Replace("\DATA", "\Backup\DB_BACKUP_NAME.BAK") ' -- set the path where backup file will be stored
Dim bkDevItem As New BackupDeviceItem(OrigBackupPath, DeviceType.File) ' -- create SMO.Backupdevice object
With oBackup ' Set the backup object property
.Action = BackupActionType.Database
.Database = YOUR_DATABASE_NAME
.Devices.Add(bkDevItem)
.Initialize = True
.Checksum = True
.ContinueAfterError = True
.Incremental = False
.LogTruncation = BackupTruncateLogType.Truncate
.SqlBackup(oSQLServer) ' backup SQL database
End With
End Sub

my regards to you
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft VB .NET 0 8th Oct 2008 07:12 AM
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft Dot NET 0 8th Oct 2008 07:11 AM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com Microsoft ASP .NET 0 3rd May 2008 01:43 PM
How to debug sql 2005 on remote machine. I am administrator on both my dev machine and remote sql server machine. DR Microsoft Dot NET Framework 0 2nd Nov 2007 10:05 PM
How to debug sql 2005 on remote machine. I am administrator on both my dev machine and remote sql server machine. DR Microsoft Dot NET 0 2nd Nov 2007 10:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 PM.