Forum Informatika
Silahkan Login

Kami sarankan anda register atau daftar terlebih dahulu agar anda dapat mendownload atau membuka category forum secara keseluruhan....
karena ada beberapa forum yang tertutup untuk tamu dan dengan Login Anda bisa menggunakan fasilitas Chatting yang kami miliki.

Selamat Bergabung

Forum Informatika

Created By Hanafi Sukawa Ginting
 
HomeFAQPasang Iklanfacebook InformatikaRegisterLog inNew Tab Newscomputer

Share | 
 

 Backup Dan Restore Database SQLSERVER2005 dengan VB.Net

View previous topic View next topic Go down 
AuthorMessage


Change Your Avatar -------------->


admin

Admin
Rank : Admin


My Pets :
Jumlah posting : 550
Point : 2147483647
Reputasi : 47
Join date : 2010-04-23
Age : 24
Lokasi : indonesia

PostSubject: Backup Dan Restore Database SQLSERVER2005 dengan VB.Net   Mon 17 Oct 2011, 21:08


Aplikasi ini di gunakan untuk Backup dan restore database dari SQL SERVER 2005.
File backup dan restore berupa file .BAK

Berikut Koding program

Code:
Imports System.Data.SqlClient
Public Class FrmBackup
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox3.Text = "" Then
            MsgBox("Isi Database", MsgBoxStyle.Critical)
        ElseIf TextBox1.Text = "" Then
            MsgBox("Silahkan cari tempat penyimpanan", MsgBoxStyle.Critical)
        Else
            MulaiBackup()
        End If
    End Sub
    Private Sub MulaiBackup()
        Try
            cmd1 = New SqlCommand("BACKUP DATABASE " & TextBox3.Text & " TO  DISK = N'" & TextBox1.Text & "' WITH NOFORMAT, NOINIT,  NAME = N'gudang_6309249-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10", con1)
            cmd1.ExecuteNonQuery()
            cmd1.Dispose()
            MsgBox("Backup sukses", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("Backup gagal", MsgBoxStyle.Critical)
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub MulaiRestore()
        Try
            cmd1 = New SqlCommand("RESTORE DATABASE " & TextBox3.Text & " FROM  DISK = N'" & TextBox2.Text & "' WITH  FILE = 1,  NOUNLOAD,  STATS = 10", con1)
            cmd1.ExecuteNonQuery()
            cmd1.Dispose()
            MsgBox("restore sukses", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("restore gagal", MsgBoxStyle.Critical)
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim fdlg As SaveFileDialog = New SaveFileDialog()
        fdlg.Title = "Simpan Backup File(Bak FIle)"
        fdlg.InitialDirectory = "c:\"
        fdlg.Filter = "All files (*.*)|*.*|BAK FIle (*.bak*)|*.bak"
        fdlg.FilterIndex = 2
        fdlg.RestoreDirectory = True
        If fdlg.ShowDialog() = DialogResult.OK Then
            TextBox1.Text = fdlg.FileName
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If TextBox3.Text = "" Then
            MsgBox("Isi Database", MsgBoxStyle.Critical)
        ElseIf TextBox2.Text = "" Then
            MsgBox("Silahkan cari file backup", MsgBoxStyle.Critical)
        Else
            MulaiRestore()
        End If
    End Sub

    Private Sub FrmBackup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        koneksi1()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim fdlg As OpenFileDialog = New OpenFileDialog()
        fdlg.Title = "Cari Backup File(Bak FIle)"
        fdlg.InitialDirectory = "c:\"
        fdlg.Filter = "All files (*.*)|*.*|BAK FIle (*.bak*)|*.bak*"
        fdlg.FilterIndex = 2
        fdlg.RestoreDirectory = True
        If fdlg.ShowDialog() = DialogResult.OK Then
            TextBox2.Text = fdlg.FileName
        End If
    End Sub
End Class



Download Sourecode Backup dan Restore
Back to top Go down
http://software-download1001.blogspot.com/
 

Backup Dan Restore Database SQLSERVER2005 dengan VB.Net

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Forum Informatika :: iklan-
Jump to:  

Create a forum on Forumotion | © phpBB | Free forum support | Contact | Report an abuse | Free forum