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
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click dim str1 as string = "d:/mrfu/newaccess" dim str2 as string = "newaccess"
if file.exists("d:/mrfu/newmdb.mdb") then msgbox("the file have exists !") exit sub
end if if createaccessdb(str1) then msgbox("sucess!") else msgbox("failed!")
end if 'me.savefiledialog1
end sub
private sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.click