SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - 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

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

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


    (Page 4 of 5 )

    This is a very simple utility to take a backup of an entire specified database and restore it whenever needed using just two buttons, two labels and a progress bar on the windows form.  Even though I hard coded some parameters such as instance name, user id, password, file name, database name, and so on, you can further extend this utility to present a better UI so that the tool accepts everything from the user dynamically.  Make sure that my focus basically is not on UI, but on using SQL-DMO with a simple little code.  I hope you agree with me.

    The utility basically contains only a single tiny windows form with the following controls on it:

    • LblMessage to provide status messages like ‘Backup process started..’ etc.
    • LblPercent to provide the status of process operation (backup/restore) in the form of a percentage value.
    • ProgressBar1 to provide the status of a process operation (backup/restore) in a fancy way i.e., just for a better appearance.
    • BtnBackup to start the process of Backup Operation.
    • BtnRestore to start the process of Restore Operation

    The following are the main declarations of SQL-DMO objects used:

    Dim oSQLServer As New SQLDMO.SQLServer

    Dim WithEvents oBackup As New SQLDMO.Backup

    Dim WithEvents oRestore As New SQLDMO.Restore

    oSQLServer is used to connect to SQL Server instance, oBackup to work with the backup operation and oRestore to work with the restore operation.  The word WithEvents raises the respective PercentComplete (gives the progress) event of either oBackup or oRestore objects, when either of them is in the process of operation.

    The following are the hard-coded constants used as main parameters:

    Const _INSTANCE As String = "."

    Const _USER As String = "sa"

    Const _PWD As String = ""

    Const _BACKUPFILE As String = "c:NorthwindBackup.bkp"

    Const _DATABASE As String = "Northwind"

    _INSTANCE specifies instance name (in this context localhost).  _USER specifies the userid to logon to instance with the respective password specified using _PWD.  The entire backup is taken into an incremental backup file (every backup gets added to an already existing backup, but within that same file) specified using _BACKUPFILE.  The restore process gets the latest backup within the same backup file.  The backup and restore operations work on the database specified with _DATABASE.

    The main backup or restore processes are explained on the next page.

    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

    Click Here




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