国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

VB.Net中動(dòng)態(tài)創(chuàng)建Access數(shù)據(jù)庫

2024-07-10 13:05:00
字體:
供稿:網(wǎng)友

最大的網(wǎng)站源碼資源下載站,

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("錯(cuò)誤號(hào) : " & err.number.tostring & " 錯(cuò)誤描述:" & 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 窗體設(shè)計(jì)器生成的代碼 "

public sub new()
mybase.new()

'該調(diào)用是 windows 窗體設(shè)計(jì)器所必需的。
initializecomponent()

'在 initializecomponent() 調(diào)用之后添加任何初始化

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 窗體設(shè)計(jì)器所必需的
private components as system.componentmodel.icontainer

'注意:以下過程是 windows 窗體設(shè)計(jì)器所必需的
'可以使用 windows 窗體設(shè)計(jì)器修改此過程。
'不要使用代碼編輯器修改它。
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 = "創(chuàng)建access數(shù)據(jù)庫"
'
'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

with me.savefiledialog1
.addextension = true

.defaultext = "mdb"
.checkpathexists = true
.filter = "(access數(shù)據(jù)庫)*.mdb|*.mdb"
.overwriteprompt = true

.filterindex = 1
end with


if me.savefiledialog1.showdialog() = dialogresult.ok then


filename = me.savefiledialog1.filename
if filename <> "" then
msgbox(filename)
else
exit sub

end if
end if

if file.exists(filename) then
msgbox("the file have exists !")
file.delete(filename)
msgbox("had delete!")

end if

filename = filename & ";"
msgbox(filename)

if createaccessdb(filename) then
msgbox("sucess!")
else
msgbox("failed!")

end if
end sub
end class



發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 琼海市| 辰溪县| 连南| 治多县| 美姑县| 高青县| 桐庐县| 松桃| 阳高县| 岳池县| 金门县| 嘉峪关市| 安龙县| 鹤壁市| 原平市| 郯城县| 安徽省| 邛崃市| 桃源县| 图木舒克市| 万载县| 德令哈市| 农安县| 疏附县| 石狮市| 贵州省| 尖扎县| 肇州县| 苍梧县| 北海市| 清徐县| 新竹县| 高邑县| 韩城市| 屯昌县| 乌拉特前旗| 神农架林区| 密云县| 长垣县| 扶沟县| 开平市|