none
Create New Jet Database file (*.mdb) in ADO.net?? RRS feed

  • Question

  •  

    My application uses an Access database file to keep its information in kind of like a database of drawing entities of a CAD program.  The application was written in VB6 and used ADODB and ADOX.  Using an ADOX catalog, I could create a new Access mdb file as follows where the ProjectFileName file did not exist:

     

      MainConnString = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
           "Data Source='" & ProjectFileName & "'"

     

      Set cat = New ADOX.Catalog
      cat.Create MainConnString
     
      Set cn = cat.ActiveConnection

    Once the blank database file was created by the jet OLEDB provider, I could execute commands to create the schema:

      
      cn.Execute "CREATE TABLE DepTypeTbl (" & _
                    "DepTypeID AUTOINCREMENT CONSTRAINT PK_DepTypeID PRIMARY KEY," & _
                    "DepTypeDesc TEXT(10)" & _
                    ");", , adCmdText

     

    I think I see how to create the schema once the database file is created, but I can not find anything in ADO.net to use to make the Jet provider create the blank database file.

     

    I have no problem using OLEDBDataAdapters with an already created file.  If I understanding Table Adapters correctly, they are tied to a specific database file connection.  I need the program to be able to Open and work with different database files with the same schema, so I have been converting the code from VB6 to VB.Net using DataAdapters.  I just can not find a way in ADO.Net to create a blank Jet (.mdb) database file.

     

    Thanks for any help,

    Bill

     

    Tuesday, January 22, 2008 4:49 AM

Answers

All replies

  • Hello,

    You are not on good forum. Go here, you will have more chance to have answer.

     

    Tuesday, January 22, 2008 7:58 AM
  • You can still use the ADOX library (or DAO). There is no native support in .NET.

     

    How to create a Microsoft Access database by using ADOX and Visual Basic .NET

    Tuesday, January 22, 2008 12:40 PM
  • Thanks Paul,

     

    I wanted to try and convert the application to a completely native .Net application.  It looks like there is a create database capability for SQL Server in .Net.  I just didn't want to "bypass" .Net without knowing that I had to.  I knew that I could use COM (ADOX) in .Net.  I just wanted to be sure that there wasn't some native support that I just could not find.  Your statement that "there is no native support in .Net" for this answers my question.

     

    Thanks.

     

    Tuesday, January 22, 2008 2:41 PM