Calling SQL Server backup maintenance plan from VB program ?

F

fniles

I have created a backup maintenance plan in SQL Server 2005. Is there any
way to run/execute this SQL Server backup maintenance plan from VB.NET ?
Thank you.
 
G

Guest

I have created a backup maintenance plan in SQL Server 2005. Is there
any way to run/execute this SQL Server backup maintenance plan from
VB.NET ? Thank you.

Take a look at the new SQL Management Objects (SMO). I think you can call a
backup plan from there.

http://msdn2.microsoft.com/en-
us/library/microsoft.sqlserver.management.smo.backup.aspx
 
F

fniles

Thank you.
I tried the following but got an error
Dim srv As Server
srv = New Server("SQLServermachinename")
Dim db As Database
db = srv.Databases("myDbName") --> error "Failed to connect to
server SQLServermachinename

Do I need to supply either the srv or db with the User ID and password ?
Is it correct that for New Server I want to set "SQLServermachinename" to it
?

Thank you.
 
T

Tibor Karaszi

Dim srv As Server
srv = New Server("SQLServermachinename")

Above will use Windows authentication to connect to the specified server name. If you want to
connect to a named instance, well, you specify the server\instance name just as in any application.
If you want to use SQL authentication, you need to use a ServerConnection object. See:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/smo9/html/a17f72ef-e02b-47af-b58a-c4219b5bba81.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top