Table table = new Table { Name = "main" }; table.Columns.Append(textBox1.Text,typeof(string)); foreach (Column column in table.Columns) if (column.Name != "ID") { column.Attributes = ColumnAttributesEnum.adColNullable; } cat.Tables.Append(table); cat = null;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Diagnostics; namespace WindowsFormsApplication1 { using ADOX; public partial class Form1 : Form { string FilePath = "D:\\Testing1.accdb"; ADOX.Catalog cat = new ADOX.Catalog(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { CreateAndExportLegacyFile(FilePath); } private void CreateAndExportLegacyFile(string exportFilePath) { if(!File.Exists(FilePath)) { var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"; connectionString += "Data Source=" + exportFilePath + ";Jet OLEDB:Engine Type=5"; cat.Create(connectionString); } //DataTable workTable = new DataTable("Testing11"); //DataColumn workCol = workTable.Columns.Add("CustID", typeof(Int32)); //workCol.AllowDBNull = false; //workCol.Unique = true; //workTable.Columns.Add("CustLName", typeof(String)); //workTable.Columns.Add("CustFName", typeof(String)); //workTable.Columns.Add("Purchases", typeof(Double)); textBox1.Text = "XXX"; Table table = new Table { Name = "Main" }; table.Columns.Append(textBox1.Text,typeof(string)); //DataTypeEnum.adVarWChar, 50); foreach (Column column in table.Columns) if (column.Name != "ID") { column.Attributes = ColumnAttributesEnum.adColNullable; } cat.Tables.Append(table); cat = null; //Marshal.FinalReleaseComObject(table); //Marshal.FinalReleaseComObject(cat.Tables); //Marshal.FinalReleaseComObject(cat.ActiveConnection); //Marshal.FinalReleaseComObject(cat); //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(workTable); //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat.Tables); //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat.ActiveConnection); //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)