adVarWchar And adInteger are 'old' vb6 constants - VB.NEt may use ADOX.DataTypeEnum.adInteger 0r something. Prolly the same deal with your Table type i.e. ADOX.Table.
Sorry dont have VS.NEt here so cant check but hope this is a lead.
I thought there is something missing too . I should've mentioned that you need to map these variables to the ADOX.DataTypeEnum . Here is the .NET Code :
VB Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Shows how to create an Access 2000 database and append tables, fields, indexes using ADOX. Don't forget
'a reference to ADOX (Microsoft ADO Ext. 2.x for DDL and Security)
Since some guys have faced some problems with finding ADOX Library , I put it here . Just unpack and copy it in your project folder then reference it .
This referenced dll exist on both XP , Win200 but I'm not sure about older versions of Windows (ME,Win98) nor WinServer 2003. .So I'd suggest to make a copy in your project folder , just in case you face some problems while deployment .
I have a question about using ADOX. Is there a way to create the access file as a hidden file?
Code:
Call this method after you make sure the db is created .Probably after this line :
ADOXtable.Indexes.Append(ADOXindex)
private void CreateMDBHidden(string MdbFile)
{
try
{
if (File.Exists(MdbFile))File.SetAttributes(MdbFile,FileAttributes.Hidden);
}
catch ( Exception x)
{
MessageBox.Show(x.Message);
}
}
I didn't test the code yet but it looks it works .
Re: VB.NET - Create new MS Access Database using ADOX
Hello Pirate, I'v followed your code and it does work. But I have another question: how to create multiple tables and establish relationship between them?
Re: VB.NET - Create new MS Access Database using ADOX
I can create a Database with ADOX Class but i have some problem in disconnecting from created database... these codes can not disconnect the program from the created database:
Re: VB.NET - Create new MS Access Database using ADOX
I get a "Value Does Not Fall Within Expected Range"
Here Is My Code, I prbly messed it up.
vb Code:
Private Sub NewDatabaseToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewDatabaseToolStripMenuItem.Click
Dim ADOXcatalog As New ADOX.Catalog
Dim ADOXtable As New ADOX.Table
Dim ADOXindex As New ADOX.Index
On Error GoTo errhandler
ADOXcatalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Documents and Settings\Tdupre8863\Desktop\Accounts.mdb")
On Error Resume Next
ADOXcatalog.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Documents and Settings\Tdupre8863\Desktop\Accounts.mdb"
Re: VB.NET - Create new MS Access Database using ADOX
Originally Posted by Jomz87
Hi anybody?
pls. HELP me on how to create database.
pls. help me to have a codes of this data:
Entering Name and Address
then the checklist like example,
Gender:
O Male
O Female
Age: ____
and then SAVE, ADD, EDIT and DELETE.
this what codes i need. Pls. help guys.
The last few years I've found it far easier to simply create an empty database (or one with a few tables), include it in the project, then whenever I need a new db created in the program I simply copy it to the desired location with a meaningful name, then if a few tables need to be created, I just use the CREATE TABLE sql statement. Completely cuts out the frustrations of using ADOX.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.