agentleong
Nov 3rd, 2000, 04:22 AM
Hi there,
I'm a newbie in VB, I need to create a simple database with some table using ADO without using control.
Anyone who knows or has the sample code, please kindly share it..
------------------------------------------------------------
Public Sub createDB()
Dim ADOConnection As New ADODB.Connection
On Error GoTo ErrorHandler
' Create a new database called JetStoredProcedure.mdb
'ADODB.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & DBPath
' Set the Connection Properties and open the connection.
With ADOConnection
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "Data Source=" & App.Path & DBPath
'Create a new table
.Execute "Create Table tblInvoice(InvNo text(50), InvDate Date, pathFileName text(128))"
End With
' Clean up
ADOConnection.Close
Set ADOConnection = Nothing
Exit Sub
ErrorHandler:
If Err = 53 Then
Resume Next
End If
MsgBox Error & " Error# " & Err
Exit Sub
End Sub
-----------------------------------------------------------
Thanks a lot,
AL
I'm a newbie in VB, I need to create a simple database with some table using ADO without using control.
Anyone who knows or has the sample code, please kindly share it..
------------------------------------------------------------
Public Sub createDB()
Dim ADOConnection As New ADODB.Connection
On Error GoTo ErrorHandler
' Create a new database called JetStoredProcedure.mdb
'ADODB.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & DBPath
' Set the Connection Properties and open the connection.
With ADOConnection
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "Data Source=" & App.Path & DBPath
'Create a new table
.Execute "Create Table tblInvoice(InvNo text(50), InvDate Date, pathFileName text(128))"
End With
' Clean up
ADOConnection.Close
Set ADOConnection = Nothing
Exit Sub
ErrorHandler:
If Err = 53 Then
Resume Next
End If
MsgBox Error & " Error# " & Err
Exit Sub
End Sub
-----------------------------------------------------------
Thanks a lot,
AL