vb.net备份还原access数据库的代码 最近在用vb.net做一个信息管理系统,想问下怎么备份还原数据库 用的是access数据库希望哪位大哥大姐帮个忙给个代码
界面上面有三个控件:Datagridview1,和两个按钮
,代码如下:
Imports System。Data。OleDb
Public Class Form1
Public LeafFileName As String = CurDir() & "\Access。 mdb" '这里是数据库文件路径和名称,你自己改
Public LeafFormName As String = "projects" '这里是你要读取这个数据库内的表的名称
Public LeafPassWord As String = "leafsoftpassword" '这里是数据库密码,如果没有密码就随便
Pub...全部
界面上面有三个控件:Datagridview1,和两个按钮
,代码如下:
Imports System。Data。OleDb
Public Class Form1
Public LeafFileName As String = CurDir() & "\Access。
mdb" '这里是数据库文件路径和名称,你自己改
Public LeafFormName As String = "projects" '这里是你要读取这个数据库内的表的名称
Public LeafPassWord As String = "leafsoftpassword" '这里是数据库密码,如果没有密码就随便
Public LeafData As DataTable
Public LeafNewRow As DataRow
Dim LeafOleDbConnection As OleDbConnection
Dim LeafOleDbCommand As OleDbCommand
Dim LeafOleDbDataAdapter As OleDbDataAdapter
Dim LeafCommandBuilder As OleDbCommandBuilder
Private Sub Form1_Load(ByVal sender As System。
Object, ByVal e As System。EventArgs) Handles MyBase。Load
Button1。Text = "读取"
Button2。
Text = "保存"
End Sub
Private Sub Button1_Click(ByVal sender As System。Object, ByVal e As System。
EventArgs) Handles Button1。Click
LeafOleDbConnection = New OleDbConnection("Provider=Microsoft。
Jet。OLEDB。4。0;Data Source=" & LeafFileName & ";" & "Jet OLEDB:Database Password='" & LeafPassWord & "';")
LeafOleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM " & LeafFormName, LeafOleDbConnection)
LeafData = New DataTable
LeafOleDbDataAdapter。
Fill(LeafData)
LeafNewRow = LeafData。NewRow
DataGridView1。DataSource = LeafData
End Sub。
收起