日期:2009-10-09  浏览次数:20593 次

Imports ADOX

Module Module1

Public Function CreateAccessDB(ByVal NewDBPathName As String) As Integer

Dim i As Integer = 1
Dim cat As Catalog = New Catalog()
Try
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & NewDBPathName & _
"Jet OLEDB:Engine Type=5")

'Console.WriteLine("Database Created Successfully")
Catch
i = 0
MsgBox("错误号 : " & Err.Number.ToString & " 错误描述:" & Err.Description.ToString)

End Try


cat = Nothing
Return i
End Function

End Module

Imports System.IO
Imports ADOX

Public Class Form1
Inherits System.Windows.Forms.Form
Dim filename As String = ""

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
Friend WithEvents SaveFileDialog2 As System.Windows.Forms.SaveFileDialog
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog()
Me.SaveFileDialog2 = New System.Windows.Forms.SaveFileDialog()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(160, 104)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(232, 48)
Me.Button1.TabIndex = 0
Me.Button1.Text = "创建access数据库"
'
'SaveFileDialog1
'
Me.SaveFileDialog1.FileName = "doc1"
'
'SaveFileDialog2
'
Me.SaveFileDialog2.FileName = "doc1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(160, 192)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(224, 56)
Me.Button2.TabIndex = 1
Me.Button2.Text = "build dataase"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(592, 286)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Pr