Create an MS Access Database without MS Access
Create an MS Access database file and table with ADOX
//Set a COM Reference to "Microsoft ADO Extensions for DDL and Security"
(ADOX)
private ADOX.Catalog cat = new ADOX.Catalog();
private
ADOX.Table tbl = new ADOX.Table();
private string db_file_path;
db_file_path
= ActiveWorkbook.Path + "\\abc.mdb";
//connect to the Access
database
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=" + db_file_path;
//Create a table
tbl.Name
= "Prospects";
// First, fields are appended to the table object
// Then the table object is appended to the Tables collection
tbl.Columns.Append
"Name", adVarWChar;
tbl.Columns.Append "Company",
adVarWChar;
tbl.Columns.Append "Phone", adVarWChar;
tbl.Columns.Append
"Address", adVarWChar;
cat.Tables.Append tbl;
Set
cat = null;
MessageBox.Show()MsgBox "Table created!";
Submission Date: 1/24/2006 6:53:56 AM
Submitted
By: Peter Bromberg
My Home Page: http://www.eggheadcafe.com
By Peter Bromberg Popularity (684 Views)