Create Access Database

  • Thread starter Thread starter JAM
  • Start date Start date
You can't. This was possible in ADOX which can be accessed via COM interop
from VB.NET.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Just keep a file or embedded resource of a blank Access database somewhere.
Then when you want to create a database, copy that empty .MDB file to where
you want it, and use ADO.NET to execute SQL commands such as CREATE TABLE.

I think the only problem you might run into is setting the "Allow
Zero-Length String" property of a text field. When setting it with SQL
statements, you can not properly set this setting.

If this is not a problem, then copying a blank .MDB file and using pure
ADO.NET is certainly more elegant than interoping with ADOX. You could also
interop with DAO to set this property---I'm actually not certain which is
easier to program and deploy



Incidentally... (a bit off topic)...

The next version of SqlServer (Yukon) is supposed to have managed objects
for creating the database. If these classes follow the design pattern of
the rest of ADO.NET and use common interfaces that aren't specific to any
database (like a SqlCatalog which implements IDbCatalog), then perhaps
somebody will implement a version that can do the same with an Access
database (maybe a JetCatalog). It could possibly use ADOX on the back end.

I seem to think MS won't do it, as they seem to be phasing out Jet, but I
wouldn't rule out someone else writing it. If there is indeed a common
interface, and not just concrete classes, I would certainly be interested in
similar classes for Oracle, Db2, Jet, etc...

--Matthew W. Jackson
 
Hi Jam,

As Bill stated you cannot with ADO.NET,
This is a way with Adox in VB.net

set a reference to COM adox ext 2.x for dll and security
\\\
Dim catNewDB As New ADOX.Catalog
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\db1.mdb")
///

I hope this helps a little bit?

Cor
 
Back
Top