Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - Simple Backup/Restore Utility With SQL-DMO...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Simple Backup/Restore Utility With SQL-DMO Using VB.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 48
    2005-09-08

    Table of Contents:
  • Simple Backup/Restore Utility With SQL-DMO Using VB.NET
  • Understanding SQL-DMO Objects
  • Programming SQL-DMO using .NET
  • Backup/Restore utility using SQL-DMO with .NET
  • Understanding Backup and Restore processes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Simple Backup/Restore Utility With SQL-DMO Using VB.NET - Programming SQL-DMO using .NET


    (Page 3 of 5 )

    As specified above, SQL-DMO comes as a COM interface (unmanaged).  It can be used with any OLE automation controller as a development platform.  Now we shall see how to work with VB.NET and SQL-DMO using Visual Studio.NET 2003 Enterprise Architect as the main objective.  Working with VC#.NET is also quite similar to the steps we will discuss now (except for the syntactical differences in programming statements).

    Using Visual Studio.NET, proceed with following steps:

    • Go to File >> New >> Project
    • From the New Project Dialog, select Visual Basic Projects as Project Type and select Windows Application as Project Template (Figure 1).

      Figure 1
    • Provide ‘SQLDMOSample’ as name of the project as shown in Figure 1. (In case of C#, select Visual C# Projects accordingly).
    • Drag a button from toolbox. Go to the properties of that button and ‘name’ it as btnCheck and change ‘text’ property to Check Connectivity
    • Go to Project Menu and click on Add Reference as in Figure 2.

      Figure 2
    • Click on the COM tab, search for Microsoft SQL DMO Object Library, double-click on it and click OK as in Figure 3.  You should see SQLDMO as a reference in Solution Explorer as in Figure 4.

      Figure 3


      Figure 4
    • In the click event of btnCheck copy the following code.  You need to change instance name, User ID and Password according to your configuration.

    Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click

            Dim oSQLServer As New SQLDMO.SQLServer

            oSQLServer.Connect("instanceName", "UserID", "Password")

            MessageBox.Show("Connected Successfully")

            oSQLServer.DisConnect()

            MessageBox.Show("Disconnected Successfully")

          End Sub

    • Press F5 to execute and you should a see a message box “Connected Successfully” (Figure 5), followed by another message box, “Disconnected Successfully”.


      Figure 5

    So, finally you tested the connectivity to SQL Server 2000 instance using SQL-DMO object SQLServer.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys, this is my article on SQL-DMO together with VB.NET. You can start...
       · Tried to download the file for the article but the link doesn't seem to...
       · Hello, I fixed that link. Thank you for pointing it out to us :-)Mike
       · backup code is working perfectly , but the restor code is not working its giving...
       · please follow the "note" section of the article. Try to close Enterprise manager...
       · Dear Jagdish,This is a wonderful article! Can you kindly help for a similar kind...
       · Hai, thanks for your compliments. And thanks again for requesting me on...
       · Hi jagdish Have u released the article about replication which was asked by...
       · Hi JagdishNice article, but I am connecting to sql server using windows...
       · Hi Sita, This is palash. I have faced a similar problem like you. Did you find any...
       · DEAR SIR I IMPLEMENTED THT CODE BUT ITS NOT WORKING ,SO PLS SEND ME RELAVT CODE or...
       · Hi There,My Backup and restore code works fine but I have one problem.It...
       · This is wonderful artical.Can u help me to take the backuo of selected table(not...
       · This helps:oSQLServer.LoginSecure = true; oSQLServer.Connect("ServerName",...
       · Hi, Thanks for such a simple and useful utility. It is really cool. it works...
       · Can anyone help me with this problem?I want to restore selected backup which can...
       · The restore cannot be done if the database is being used. So if the datagrid uses...
       · This article is simply perfect! Short, Clear and concise. Thanks a lot..For...
       · Hi Sita and PalashI am Kulwinder Singh. I found out the solution for ur...
       · where is the link? i cant download the file.. please help me.
       · I am Rohit, I am using VB.Net. I am Beginner in .Net VS 2005. I want to know how...
       · can you give me the link to download this program
       · i am jerry can you give me link to download this program:)) thank
       · Hey Thanks For The code....!!Bi!
       · Hello.. i have got an error like "type SQLDMO.SQLServer is not defined" now what to...
       · Hello Mr. chaterjee and all friends,This article is great ! I m new to back up...
       · Have you got the solution for this please reply me
     

    VISUAL BASIC.NET ARTICLES

    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway