Click here to Skip to main content
15,895,808 members
Articles / Database Development / SQL Server

SQL Server Database Backup Utility using VB.NET and SQL-DMO (New version)

Rate me:
Please Sign up or sign in to vote.
4.77/5 (26 votes)
17 Mar 2008CPOL5 min read 309.6K   21.2K   143  
A Windows application to backup and restore SQL server tables,views,user defined functions and stored procedures
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmGenerateScripts
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.txtNoOfRows = New System.Windows.Forms.TextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.txtBCPOptions = New System.Windows.Forms.TextBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.cmdDeselectAll = New System.Windows.Forms.Button
        Me.cmdSelectAll = New System.Windows.Forms.Button
        Me.cmdConnect = New System.Windows.Forms.Button
        Me.txtBackupDir = New System.Windows.Forms.TextBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.cmdGenerateScripts = New System.Windows.Forms.Button
        Me.dgExportTables = New System.Windows.Forms.DataGridView
        Me.gbLogin = New System.Windows.Forms.GroupBox
        Me.txtPassword = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.txtUsername = New System.Windows.Forms.TextBox
        Me.rdSQLServerAuthentication = New System.Windows.Forms.RadioButton
        Me.rdWindowsAuthentication = New System.Windows.Forms.RadioButton
        Me.txtDatabaseName = New System.Windows.Forms.TextBox
        Me.txtServerName = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.GroupBox1.SuspendLayout()
        CType(Me.dgExportTables, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.gbLogin.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.txtNoOfRows)
        Me.GroupBox1.Controls.Add(Me.Label8)
        Me.GroupBox1.Controls.Add(Me.txtBCPOptions)
        Me.GroupBox1.Controls.Add(Me.Label6)
        Me.GroupBox1.Controls.Add(Me.cmdDeselectAll)
        Me.GroupBox1.Controls.Add(Me.cmdSelectAll)
        Me.GroupBox1.Controls.Add(Me.cmdConnect)
        Me.GroupBox1.Controls.Add(Me.txtBackupDir)
        Me.GroupBox1.Controls.Add(Me.Label5)
        Me.GroupBox1.Controls.Add(Me.cmdGenerateScripts)
        Me.GroupBox1.Controls.Add(Me.dgExportTables)
        Me.GroupBox1.Controls.Add(Me.gbLogin)
        Me.GroupBox1.Controls.Add(Me.rdSQLServerAuthentication)
        Me.GroupBox1.Controls.Add(Me.rdWindowsAuthentication)
        Me.GroupBox1.Controls.Add(Me.txtDatabaseName)
        Me.GroupBox1.Controls.Add(Me.txtServerName)
        Me.GroupBox1.Controls.Add(Me.Label2)
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Location = New System.Drawing.Point(12, 12)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(899, 529)
        Me.GroupBox1.TabIndex = 1
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Export"
        '
        'txtNoOfRows
        '
        Me.txtNoOfRows.Location = New System.Drawing.Point(770, 171)
        Me.txtNoOfRows.Name = "txtNoOfRows"
        Me.txtNoOfRows.Size = New System.Drawing.Size(116, 20)
        Me.txtNoOfRows.TabIndex = 23
        Me.txtNoOfRows.Text = "TOP 100 PERCENT *"
        '
        'Label8
        '
        Me.Label8.AutoSize = True
        Me.Label8.Location = New System.Drawing.Point(624, 174)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(145, 13)
        Me.Label8.TabIndex = 22
        Me.Label8.Text = "Default No of rows to export :"
        '
        'txtBCPOptions
        '
        Me.txtBCPOptions.Location = New System.Drawing.Point(770, 208)
        Me.txtBCPOptions.Name = "txtBCPOptions"
        Me.txtBCPOptions.Size = New System.Drawing.Size(116, 20)
        Me.txtBCPOptions.TabIndex = 19
        Me.txtBCPOptions.Text = "-T -c"
        '
        'Label6
        '
        Me.Label6.AutoSize = True
        Me.Label6.Location = New System.Drawing.Point(698, 211)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(71, 13)
        Me.Label6.TabIndex = 18
        Me.Label6.Text = "BCP options :"
        '
        'cmdDeselectAll
        '
        Me.cmdDeselectAll.Location = New System.Drawing.Point(108, 436)
        Me.cmdDeselectAll.Name = "cmdDeselectAll"
        Me.cmdDeselectAll.Size = New System.Drawing.Size(86, 32)
        Me.cmdDeselectAll.TabIndex = 17
        Me.cmdDeselectAll.Text = "Deselect All"
        Me.cmdDeselectAll.UseVisualStyleBackColor = True
        '
        'cmdSelectAll
        '
        Me.cmdSelectAll.Location = New System.Drawing.Point(16, 436)
        Me.cmdSelectAll.Name = "cmdSelectAll"
        Me.cmdSelectAll.Size = New System.Drawing.Size(86, 32)
        Me.cmdSelectAll.TabIndex = 16
        Me.cmdSelectAll.Text = "Select All"
        Me.cmdSelectAll.UseVisualStyleBackColor = True
        '
        'cmdConnect
        '
        Me.cmdConnect.Location = New System.Drawing.Point(391, 200)
        Me.cmdConnect.Name = "cmdConnect"
        Me.cmdConnect.Size = New System.Drawing.Size(143, 35)
        Me.cmdConnect.TabIndex = 15
        Me.cmdConnect.Text = "Connect"
        Me.cmdConnect.UseVisualStyleBackColor = True
        '
        'txtBackupDir
        '
        Me.txtBackupDir.Location = New System.Drawing.Point(359, 448)
        Me.txtBackupDir.Name = "txtBackupDir"
        Me.txtBackupDir.Size = New System.Drawing.Size(327, 20)
        Me.txtBackupDir.TabIndex = 14
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(249, 451)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(104, 13)
        Me.Label5.TabIndex = 13
        Me.Label5.Text = "Script File Directory :"
        '
        'cmdGenerateScripts
        '
        Me.cmdGenerateScripts.Location = New System.Drawing.Point(425, 488)
        Me.cmdGenerateScripts.Name = "cmdGenerateScripts"
        Me.cmdGenerateScripts.Size = New System.Drawing.Size(152, 35)
        Me.cmdGenerateScripts.TabIndex = 12
        Me.cmdGenerateScripts.Text = "Generate Scripts"
        Me.cmdGenerateScripts.UseVisualStyleBackColor = True
        '
        'dgExportTables
        '
        Me.dgExportTables.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
        Me.dgExportTables.Location = New System.Drawing.Point(16, 241)
        Me.dgExportTables.Name = "dgExportTables"
        Me.dgExportTables.Size = New System.Drawing.Size(870, 189)
        Me.dgExportTables.TabIndex = 11
        '
        'gbLogin
        '
        Me.gbLogin.Controls.Add(Me.txtPassword)
        Me.gbLogin.Controls.Add(Me.Label3)
        Me.gbLogin.Controls.Add(Me.Label4)
        Me.gbLogin.Controls.Add(Me.txtUsername)
        Me.gbLogin.Location = New System.Drawing.Point(326, 110)
        Me.gbLogin.Name = "gbLogin"
        Me.gbLogin.Size = New System.Drawing.Size(265, 81)
        Me.gbLogin.TabIndex = 10
        Me.gbLogin.TabStop = False
        '
        'txtPassword
        '
        Me.txtPassword.Location = New System.Drawing.Point(81, 44)
        Me.txtPassword.Name = "txtPassword"
        Me.txtPassword.Size = New System.Drawing.Size(143, 20)
        Me.txtPassword.TabIndex = 7
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(9, 20)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(66, 13)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "User Name :"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(16, 47)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(59, 13)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "Password :"
        '
        'txtUsername
        '
        Me.txtUsername.Location = New System.Drawing.Point(81, 17)
        Me.txtUsername.Name = "txtUsername"
        Me.txtUsername.Size = New System.Drawing.Size(143, 20)
        Me.txtUsername.TabIndex = 6
        '
        'rdSQLServerAuthentication
        '
        Me.rdSQLServerAuthentication.AutoSize = True
        Me.rdSQLServerAuthentication.Checked = True
        Me.rdSQLServerAuthentication.Location = New System.Drawing.Point(404, 88)
        Me.rdSQLServerAuthentication.Name = "rdSQLServerAuthentication"
        Me.rdSQLServerAuthentication.Size = New System.Drawing.Size(173, 17)
        Me.rdSQLServerAuthentication.TabIndex = 9
        Me.rdSQLServerAuthentication.TabStop = True
        Me.rdSQLServerAuthentication.Text = "Use SQL Server Authentication"
        Me.rdSQLServerAuthentication.UseVisualStyleBackColor = True
        '
        'rdWindowsAuthentication
        '
        Me.rdWindowsAuthentication.AutoSize = True
        Me.rdWindowsAuthentication.Location = New System.Drawing.Point(404, 65)
        Me.rdWindowsAuthentication.Name = "rdWindowsAuthentication"
        Me.rdWindowsAuthentication.Size = New System.Drawing.Size(162, 17)
        Me.rdWindowsAuthentication.TabIndex = 8
        Me.rdWindowsAuthentication.Text = "Use Windows Authentication"
        Me.rdWindowsAuthentication.UseVisualStyleBackColor = True
        '
        'txtDatabaseName
        '
        Me.txtDatabaseName.Location = New System.Drawing.Point(404, 39)
        Me.txtDatabaseName.Name = "txtDatabaseName"
        Me.txtDatabaseName.Size = New System.Drawing.Size(143, 20)
        Me.txtDatabaseName.TabIndex = 5
        '
        'txtServerName
        '
        Me.txtServerName.Location = New System.Drawing.Point(404, 13)
        Me.txtServerName.Name = "txtServerName"
        Me.txtServerName.Size = New System.Drawing.Size(143, 20)
        Me.txtServerName.TabIndex = 4
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(308, 41)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(90, 13)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "Database Name :"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(323, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(75, 13)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Server Name :"
        '
        'frmGenerateScripts
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(1028, 753)
        Me.Controls.Add(Me.GroupBox1)
        Me.Name = "frmGenerateScripts"
        Me.Text = "Generate SQL Scripts"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        CType(Me.dgExportTables, System.ComponentModel.ISupportInitialize).EndInit()
        Me.gbLogin.ResumeLayout(False)
        Me.gbLogin.PerformLayout()
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents txtNoOfRows As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents txtBCPOptions As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents cmdDeselectAll As System.Windows.Forms.Button
    Friend WithEvents cmdSelectAll As System.Windows.Forms.Button
    Friend WithEvents cmdConnect As System.Windows.Forms.Button
    Friend WithEvents txtBackupDir As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents cmdGenerateScripts As System.Windows.Forms.Button
    Friend WithEvents dgExportTables As System.Windows.Forms.DataGridView
    Friend WithEvents gbLogin As System.Windows.Forms.GroupBox
    Friend WithEvents txtPassword As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtUsername As System.Windows.Forms.TextBox
    Friend WithEvents rdSQLServerAuthentication As System.Windows.Forms.RadioButton
    Friend WithEvents rdWindowsAuthentication As System.Windows.Forms.RadioButton
    Friend WithEvents txtDatabaseName As System.Windows.Forms.TextBox
    Friend WithEvents txtServerName As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions