VB.NET dynamology creation Access database

xiaoxiao2021-03-06  42

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 (" Error Number: "& Err.Number.toToString &" Error Description: "& Err.Description.toString)

END TRY

Cat = Nothing returni end function

End module

Imports System.IoImports Adox

Public class form1 inherits system.windows.Forms.form Dim filename as string = ""

#Region "Windows Form Designer Generated Code"

Public Sub new () mybase.new ()

'This call is required for the Windows Form Designer. InitializeComponent ()

'Add any initialization after INITIALIZECOMPONENT ()

End Sub

'Form rewriting disposal to clean the component list. Protected overloads overrides sub dispose (byval disposing as boolean) ing disponation kiln (Components Is Nothing) Then components.dispose () end if endiffs) End sub

'Windows Form Designer Supply Private Components as System.comPonentModel.icontainer

'Note: The following procedure is necessary to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.

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 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 = "Create database access" '' SaveFileDialog1 'Me.SaveFileDialog1.FileName = "doc1"' 'SaveFileDialo G2 'me.savefiledialog2.filename = "DOC1"' '' button = 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 data" '' 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 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 CREATEACCESSDB (STR1) THEN MSGBOX ("Sucess!") Else Msgbox ("failed!")

End if 'me.savefiledialog1

End Sub

Private sub Button2_click (byvalgend, byval e as system.eventargs) Handles Button2.click

With me.savefiledialog1 .addextension = True

.Defaultext = "MDB" .checkpathexists = true .filter = "(access database) *. 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 endiff

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 Subend Class

转载请注明原文地址:https://www.9cbs.com/read-51801.html

New Post(0)