Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > อาจารย์เขาต้องการให้ทำ backup restall ข้อมูลกรณี ทำ ๆ ไปแล้วคนที่เป็น admin ทำข้อมูลสูญหายก็สามารถเรียกข้อมูลเดิมมาได้



 

อาจารย์เขาต้องการให้ทำ backup restall ข้อมูลกรณี ทำ ๆ ไปแล้วคนที่เป็น admin ทำข้อมูลสูญหายก็สามารถเรียกข้อมูลเดิมมาได้

 



Topic : 102418

Guest




อาจารย์เขาต้องการให้ทำ backup restall ข้อมูลกรณี ทำ ๆ ไปแล้วคนที่เป็น admin ทำข้อมูลสูญหายก็สามารถเรียกข้อมูลเดิมมาได้ ไม่มีว่าต้องเขียนแบบไหนนะ 55 ก็เลยขอความกรุณาช่วยหน่อยนะ



Tag : .NET, Ms Access, Crystal Report, VS 2010 (.NET 4.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-11-06 14:49:02 By : สมองน้อย View : 891 Reply : 15
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

รู้สึกจะตอบไปก่อนหน้านี้แล้วน่ะครับ เกี่ยวกับการ Backup จาก MS Access






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 06:36:40 By : mr.win
 


 

No. 2

Guest


แค่ Copy database (MS Access) ไปไว้อีกที่หนึ่งแค่นั้นเอง ง่าย ๆ ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 09:38:07 By : ผ่านมาเห็นแล้วอยากช่วย
 

 

No. 3

Guest


แล้วถ้าจะรีสโตกลับมาใช้ใหม่ล่ะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 10:33:59 By : สมองน้อย
 


 

No. 4

Guest


ตอบความคิดเห็นที่ : 3 เขียนโดย : สมองน้อย เมื่อวันที่ 2013-11-07 10:33:59
รายละเอียดของการตอบ ::
ถ้าจะ restore ก็ copy กลับมา replace ของเดิมจิ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 10:57:34 By : ห้ามตอบเกินวันละ 2 กระทู้
 


 

No. 5

Guest


-ขอตัวอย่างได้มั้ยค่ะ รบกวนด้วยนะค่ะจนปัญญาจริงๆ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 11:32:07 By : สมองน้อย
 


 

No. 6

Guest


รบกวนจริงนะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 11:52:21 By : สมองน้อย
 


 

No. 7

Guest


1


โชว์ไฟล์ทั้งหมด โดยกดปุ่มตามรูป
2


ก็อป database วางไว้ใน folder debug
3


จากนั้น copy โค้ดไปวาง

Form1.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    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)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    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()
        Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Me.ButtonBackup = New System.Windows.Forms.Button()
        Me.ButtonRestore = New System.Windows.Forms.Button()
        Me.DataGridView1 = New System.Windows.Forms.DataGridView()
        Me.BackgroundWorker1 = New System.ComponentModel.BackgroundWorker()
        Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
        Me.Index = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.DatabaseDate = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.BackupDate = New System.Windows.Forms.DataGridViewTextBoxColumn()
        CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'ButtonBackup
        '
        Me.ButtonBackup.Location = New System.Drawing.Point(12, 41)
        Me.ButtonBackup.Name = "ButtonBackup"
        Me.ButtonBackup.Size = New System.Drawing.Size(75, 23)
        Me.ButtonBackup.TabIndex = 0
        Me.ButtonBackup.Text = "Back up"
        Me.ButtonBackup.UseVisualStyleBackColor = True
        '
        'ButtonRestore
        '
        Me.ButtonRestore.Location = New System.Drawing.Point(358, 41)
        Me.ButtonRestore.Name = "ButtonRestore"
        Me.ButtonRestore.Size = New System.Drawing.Size(75, 23)
        Me.ButtonRestore.TabIndex = 1
        Me.ButtonRestore.Text = "Restore"
        Me.ButtonRestore.UseVisualStyleBackColor = True
        '
        'DataGridView1
        '
        Me.DataGridView1.AllowUserToAddRows = False
        Me.DataGridView1.AllowUserToDeleteRows = False
        Me.DataGridView1.AllowUserToResizeColumns = False
        Me.DataGridView1.AllowUserToResizeRows = False
        Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
        Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Index, Me.DatabaseDate, Me.BackupDate})
        Me.DataGridView1.Location = New System.Drawing.Point(12, 70)
        Me.DataGridView1.MultiSelect = False
        Me.DataGridView1.Name = "DataGridView1"
        Me.DataGridView1.RowHeadersVisible = False
        Me.DataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect
        Me.DataGridView1.Size = New System.Drawing.Size(421, 199)
        Me.DataGridView1.TabIndex = 2
        '
        'BackgroundWorker1
        '
        Me.BackgroundWorker1.WorkerReportsProgress = True
        Me.BackgroundWorker1.WorkerSupportsCancellation = True
        '
        'ProgressBar1
        '
        Me.ProgressBar1.Location = New System.Drawing.Point(12, 12)
        Me.ProgressBar1.Name = "ProgressBar1"
        Me.ProgressBar1.Size = New System.Drawing.Size(421, 23)
        Me.ProgressBar1.TabIndex = 3
        '
        'Index
        '
        Me.Index.DataPropertyName = "Index"
        Me.Index.HeaderText = "#"
        Me.Index.Name = "Index"
        Me.Index.ReadOnly = True
        Me.Index.Resizable = System.Windows.Forms.DataGridViewTriState.[False]
        Me.Index.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable
        Me.Index.Width = 30
        '
        'DatabaseDate
        '
        Me.DatabaseDate.DataPropertyName = "DatabaseDate"
        DataGridViewCellStyle1.Format = "G"
        DataGridViewCellStyle1.NullValue = Nothing
        Me.DatabaseDate.DefaultCellStyle = DataGridViewCellStyle1
        Me.DatabaseDate.HeaderText = "Database Date"
        Me.DatabaseDate.Name = "DatabaseDate"
        Me.DatabaseDate.ReadOnly = True
        Me.DatabaseDate.Resizable = System.Windows.Forms.DataGridViewTriState.[False]
        Me.DatabaseDate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable
        Me.DatabaseDate.Width = 185
        '
        'BackupDate
        '
        Me.BackupDate.DataPropertyName = "BackupDate"
        DataGridViewCellStyle2.Format = "G"
        DataGridViewCellStyle2.NullValue = Nothing
        Me.BackupDate.DefaultCellStyle = DataGridViewCellStyle2
        Me.BackupDate.HeaderText = "Back up Date"
        Me.BackupDate.Name = "BackupDate"
        Me.BackupDate.ReadOnly = True
        Me.BackupDate.Resizable = System.Windows.Forms.DataGridViewTriState.[False]
        Me.BackupDate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable
        Me.BackupDate.Width = 185
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(445, 281)
        Me.Controls.Add(Me.ProgressBar1)
        Me.Controls.Add(Me.DataGridView1)
        Me.Controls.Add(Me.ButtonRestore)
        Me.Controls.Add(Me.ButtonBackup)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Form1"
        CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents ButtonBackup As System.Windows.Forms.Button
    Friend WithEvents ButtonRestore As System.Windows.Forms.Button
    Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView
    Friend WithEvents BackgroundWorker1 As System.ComponentModel.BackgroundWorker
    Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
    Friend WithEvents Index As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents DatabaseDate As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents BackupDate As System.Windows.Forms.DataGridViewTextBoxColumn

End Class


Form1.vb
Imports System.Data.OleDb
Imports System.IO

Public Class Form1

    Private dbName As String

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        dbName = "Nwind.accdb" ' เปลี่ยนชื่อ database ที่นี่

        If Not File.Exists(String.Format("{0}\{1}", Application.StartupPath, dbName)) Then
            MessageBox.Show("Cann't find database file.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Me.Close()
        End If

        Dim backupFolder As New DirectoryInfo(String.Format("{0}\backup", Application.StartupPath))

        If Not backupFolder.Exists() Then
            backupFolder.Create()
        End If

        BindData()

        ButtonRestore.Enabled = False
    End Sub

    Private Sub ButtonBackup_Click(sender As System.Object, e As System.EventArgs) Handles ButtonBackup.Click
        Dim result As DialogResult : result = MessageBox.Show("Do you want to back up database?", "Confrim", MessageBoxButtons.YesNo)

        If result = Windows.Forms.DialogResult.Yes Then
            ButtonBackup.Enabled = False
            ButtonRestore.Enabled = False
            DataGridView1.Enabled = False

            BackgroundWorker1.RunWorkerAsync(Action.Backup)
        End If
    End Sub

    Private Sub ButtonRestore_Click(sender As System.Object, e As System.EventArgs) Handles ButtonRestore.Click
        Dim result As DialogResult : result = MessageBox.Show("Do you want to restore database?", "Confrim", MessageBoxButtons.YesNo)

        If result = Windows.Forms.DialogResult.Yes Then
            ButtonBackup.Enabled = False
            ButtonRestore.Enabled = False
            DataGridView1.Enabled = False

            BackgroundWorker1.RunWorkerAsync(Action.Restore)
        End If
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim act As Action : act = DirectCast(e.Argument, Action)

        Select Case act
            Case Action.Backup
                BackUp()
            Case Else
                Restore()
        End Select
    End Sub

    Private Sub BackgroundWorker1_ProgressChanged(sender As System.Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
        ProgressBar1.Value = e.ProgressPercentage
    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(sender As System.Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        ButtonBackup.Enabled = True
        ButtonRestore.Enabled = False
        DataGridView1.Enabled = True

        ProgressBar1.Value = 0

        BindData()
    End Sub

    Private Sub DataGridView1_CellClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        ButtonRestore.Enabled = True
    End Sub

    Private Sub BackUp()
        Dim dbFile As New FileInfo(String.Format("{0}\{1}", Application.StartupPath, dbName))
        Dim dbFolderPath As String : dbFolderPath = String.Format("{0}\backup\{1}", Application.StartupPath, dbFile.LastWriteTime.ToString("ddMMyyyyhhmmss"))
        Dim dbFolder As New DirectoryInfo(dbFolderPath)

        If Not dbFolder.Exists Then
            dbFolder.Create()

            BackgroundWorker1.ReportProgress(50)

            dbFile.CopyTo(String.Format("{0}\{1}", dbFolderPath, dbFile.Name))

            BackgroundWorker1.ReportProgress(100)

            MessageBox.Show("Back up Complete!", "Complete")
        Else
            MessageBox.Show("Back up database is exist.", "Cann't back up!", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

    Private Sub Restore()
        Dim dbFile As New FileInfo(String.Format("{0}\{1}", Application.StartupPath, dbName))
        Dim selectedFolder As String : selectedFolder = Convert.ToDateTime(DataGridView1.SelectedRows.Item(0).Cells(1).Value).ToString("ddMMyyyyhhmmss")
        Dim restoreFile As New FileInfo(String.Format("{0}\backup\{1}\{2}", Application.StartupPath, selectedFolder, dbName))

        If Not DateTime.Compare(dbFile.LastWriteTime, restoreFile.LastWriteTime) = 0 Then
            BackgroundWorker1.ReportProgress(50)

            dbFile.CopyTo(String.Format("{0}\{1}", Application.StartupPath, dbFile.Name), True)

            BackgroundWorker1.ReportProgress(100)

            MessageBox.Show("Restore Complete!", "Complete")
        Else
            MessageBox.Show("Back up and restore database is same.", "Cann't restore!", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If

    End Sub

    Private Sub BindData()
        Dim dbFile As New FileInfo(String.Format("{0}\{1}", Application.StartupPath, dbName))
        Me.Text = String.Format("Database: {0}", dbFile.LastWriteTime.ToString("dd/MM/yyyy hh:mm:ss"))

        Dim backupFolder As New DirectoryInfo(String.Format("{0}\backup", Application.StartupPath))
        Dim childFolder() As DirectoryInfo : childFolder = backupFolder.GetDirectories()

        Dim dt As New DataTable
        dt.Columns.Add("Index", GetType(Integer))
        dt.Columns.Add("DatabaseDate", GetType(Date))
        dt.Columns.Add("BackupDate", GetType(Date))

        Dim count As Integer : count = 0

        For Each child As DirectoryInfo In childFolder
            count = count + 1

            Dim backupFile As New FileInfo(String.Format("{0}\{1}", child.FullName, dbName))

            Dim dr As DataRow : dr = dt.NewRow()
            dr("Index") = count
            dr("DatabaseDate") = backupFile.LastWriteTime
            dr("BackupDate") = child.CreationTime
            dt.Rows.Add(dr)
        Next

        DataGridView1.DataSource = dt
        DataGridView1.ClearSelection()
    End Sub

    Private Enum Action
        Backup
        Restore
    End Enum

End Class


รันดู

4
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 12:44:25 By : ห้ามตอบเกินวันละ 2 กระทู้
 


 

No. 9

Guest


.jpg
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 14:01:53 By : สมองน้อย
 


 

No. 10

Guest


.jpg
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 14:04:46 By : สมองน้อย
 


 

No. 11

Guest


ช่วยหน่อยนะค่ะคุณ ห้ามตอบเกินวันละ 2 กระทู้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 14:09:14 By : สมองน้อย
 


 

No. 12

Guest


กรณีเดียวกันแบบนี้แหละ

สาเหตุจากชื่อ namespace ชนกัน

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_26771758.html

อ่านแล้วแก้เองแล้วกัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 14:31:28 By : ห้ามตอบเกินวันละ 2 กระทู้
 


 

No. 13

Guest


ไม่เข้าใจค่ะยังไม่ได้เลยพยายามแล้วค่ะ ช่วยอีกนิดหนึ่งนะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 15:34:51 By : สมองน้อย
 


 

No. 14

Guest


โน................... ทำเองมั้ง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-07 15:50:27 By : ห้ามตอบเกินวันละ 2 กระทู้
 


 

No. 15

Guest


พอรีสตอแล้วมันขึ้นแบบนี้อ่ะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 13:31:18 By : สมองน้อย
 


 

No. 16

Guest


access มีการเปิดใช้งานอยู่

ต้อง close connection ก่อน ถึงจะ replace ได้

ว่าแต่เปิด connection ทิ้งไว้ทำไมอ่ะ ใช้เสร็จแล้วก็ปิดสิ

ใช้เมื่อไหร่ค่อยเปิด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 13:49:40 By : ห้ามตอบเกินวันละ 2 กระทู้
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อาจารย์เขาต้องการให้ทำ backup restall ข้อมูลกรณี ทำ ๆ ไปแล้วคนที่เป็น admin ทำข้อมูลสูญหายก็สามารถเรียกข้อมูลเดิมมาได้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่