Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2003, 08:38 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can you Create a Jet 4 Database using VB.NET ?

Hi,

I wonder if anyone could point me in the right direction...

I would like to create a Jet 4.0 (Access) database, but using VB.NET/ASP.NET not COM.

Background :-

I have access, but have an app written in VB.NET that connects to an access database which is specified by the user. What I would like to happen is if the database doesn't exist, for the app to create it.



Regards,
Mark Jarvis
 
Old June 28th, 2003, 03:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

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
 
Old June 29th, 2003, 12:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Looked a little further into this and it appears that you still
have to use ADOX through COM Interop. I don't believe there is
a 'pure' .NET solution.

Bob
 
Old July 1st, 2003, 03:18 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your time Bob, :)

I have also looked around before posting this... But could only find COM solutions. I was hoping to keep the layers of complexity down to a minimum, for moving the app around, etc.... But hay, at-least there is a solution.

Thanks again.

If anyone does come across a pure .Net solution please let us know :D

Thanks again Bob.

Regards
Mark

Regards,
Mark Jarvis
 
Old July 1st, 2003, 03:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by jarvism
...
If anyone does come across a pure .Net solution please let us know :D
From Microsoft MSDN: "The Microsoft Jet OLE DB Provider and other related components were removed from MDAC 2.6. Microsoft has deprecated the Microsoft Jet Engine, and plans no new releases or service packs for this component." See:http://msdn.microsoft.com/library/de...deprecated.asp

From that statement I think its safe to say that I doubt you'll see any enhancements in .NET supporting JET...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old July 1st, 2003, 08:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Microsoft has "deprecated" the Microsoft Jet Engine? MDAC 2.8 meets English 101. Another perfectly good word bites the dust.
 
Old July 1st, 2003, 08:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by Bob Bedell
 Microsoft has "deprecated" the Microsoft Jet Engine? MDAC 2.8 meets English 101. Another perfectly good word bites the dust.
Huh?

I've seen "deprecated" used often this industry, not just by Microsoft, to mean a feature or capability no longer recommended for further use. That fits pretty well with the definition in my dictionary: "Deprecate: 1. To express disapproval of." Which dictionary are you using in your English 101 class that contradicts that?

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old July 1st, 2003, 10:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Seems a bit strong to me, don't you think. Indeed, it does mean "to express disapproval," but with the obvious connotation of strong disapproval, as in to deplore, to disparage, to condemn, to belittle, synonymns and near synonyms that I'm sure your dictionary lists as well if you hadn't stopped at usage 1.

We're retiring a technology here, not berating it for having failed to fulfill our expectations.

From the Latin: deprecari, deprecat-: to ward off by prayer. Hmmm...That is something I have simply never felt moved to do in the presence of the Jet engine. A slightly less value ladden term would seem more appropriate here.

See, if you ever get bored writing SQL the whole wonderful world of etymology awaits you!

Oh, I hope that didn't come across deprecatorily. :)
 
Old July 2nd, 2003, 06:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

While this is certainly is off topic and getting a bit afield of the original post, I found this interesting article concerning the current evolution of the meaning of the word deprecate, especially from a computer technology point of view:

http://www.worldwidewords.org/topicalwords/tw-dep1.htm

You go on to say:
Quote:
quote:
From the Latin: deprecari, deprecat-: to ward off by prayer. Hmmm...That is something I have simply never felt moved to do in the presence of the Jet engine.
You've obviously never worked with the JET Engine in a multi-user environment. If you had, you'd realize prayer was a useful tool to keep the database from corrupting itself. :)

(deprecatorily? you want to talk about maiming the English language :D )

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old July 2nd, 2003, 12:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

"(deprecatorily? you want to talk about maiming the English language )"

OK, so I was reaching here...at least its a legitimate adverb.

But you'll have to concede that "this jargon sense [of deprecate] is not in any mainstream dictionary".

Its simply that - jargon - which is, of course, my point.

I think, however, that the more interesting questions revolve around what's next for Access, now that Jet has been deprecated. Access.NET as the DBMS for SQL Server????





Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft JET Database Database Engine (0x80040E09 cannielynn0312 Classic ASP Professional 2 December 17th, 2007 02:50 AM
Best way to create a Report in VB.NET ETSUSnake VB How-To 0 October 23rd, 2006 11:54 AM
how can i create messanger in vb.net sanjay_jadam General .NET 1 January 21st, 2005 07:47 AM
Create a PDF with VB.NET medwar76 Pro VB.NET 2002/2003 5 October 29th, 2003 01:16 PM
Create a PDF with VB.NET medwar76 VS.NET 2002/2003 0 September 4th, 2003 02:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.