Hi,
Is it possible to create a new database at the runtime?
If yes how and if not why?
Thanks
Printable View
Hi,
Is it possible to create a new database at the runtime?
If yes how and if not why?
Thanks
Search for ADOX you will find many examples here..Quote:
Originally posted by junk
Hi,
Is it possible to create a new database at the runtime?
If yes how and if not why?
Thanks
http://www.vbforums.com/search.php?s...ost&sortorder=
VB Code:
'Add a reference to Microsoft ADO Ext. X.X For DLL And Security Option Explicit Dim cat As ADOX.Catalog Dim tbl As ADOX.Table Private Sub Command1_Click() Set cat = New ADOX.Catalog Set tbl = New ADOX.Table ' create the db cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\newDB3.mdb" With tbl .Name = "TestTable" ' Create fields and append them to the ' Columns collection of the new Table object. With .Columns .Append "ID COLUMN" .Append "SetName", adVarWChar, 255 .Append "SetVal", adVarWChar, 255 .Append "Description", adVarWChar, 255 End With End With ' Add the new Table to the Tables collection of the database. cat.Tables.Append tbl 'Set AllowZeroLength to true for the SetName field tbl.Columns("SetName").Properties("Jet OLEDB:Allow Zero Length") = True Set cat = Nothing Set tbl = Nothing End Sub
and yes.. you would proabaly find this when searcing :)
Just out of curiosity (and because of the project i'm working on as my semeser project for school) would this work in vb.net 2003? If not, how would i create a new access database in vb.net 2003? Oh yeah, i found this thread by searching :)
Hi IceBreakerG,
this will NOT work in VB .Net.
You will have to use ADO .NET
Ask the question in the VB .NET forum, I'm suer some of the good people in that forum knows how to do this.
http://www.vbforums.com/forumdisplay.php?s=&forumid=25