Hi Mark,
Did you know you don't HAVE to rule out COM just 'cause you're using
VB.NET? I you did, read on or not, but I use ADOX below to create a Jet db from a
VB.NET app, and then use .NET namespaces to connect to it and manipulate it. You can set a reference to ADOX in a .NET project by right-clicking the References folder in the Solution Explorer and selecting the COM tab. I also imported to System.IO namespace below to check and see if the .mdb file already exists or not (using the File class). Maybe it will give you some ideas...
====================================
Imports System.IO
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim path As String = "C:\Test.mdb"
Try
If Not File.Exists(path) Then
' Create .mdb file using ADOX COM library.
Dim sConnString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & path
Dim cat As New ADOX.Catalog()
cat.Create(sConnString)
' Connect to .mdb file using the System.Data.OleDb namespace.
Dim oOleDbConnection As OleDb.OleDbConnection
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
' Execute a data definition language (DDL) query using
' the System.Data.OleDb namespace and Jet SQL.
Dim strSQL As String = "CREATE TABLE tblCustomers (" & _
"CustomerID INTEGER CONSTRAINT PK_tblCustomers PRIMARY KEY, " & _
"[Last Name] TEXT(50) NOT NULL," & _
"[First Name] TEXT(50) NOT NULL," & _
"Phone TEXT(10)," & _
"Email TEXT(50));"
Dim cmd As OleDbCommand = oOleDbConnection.CreateCommand()
cmd.CommandText = strSQL
cmd.ExecuteNonQuery()
Else
' Connect to .mdb file using the System.Data.OleDb namespace.
End If
Catch er As Exception
MessageBox.Show(er.ToString)
'Finally
' oOleDbConnection.Close()
End Try
End Sub
End Class
================================================
After compiling the solution, a 'Interop.ADOX.dll' file appears in the 'bin' directory, and the db is on the C: drive.
hth
Bob