private void OnFormClosed(object sender, FormClosedEventArgs e) { global.SaveFormSettings(this); _dbData.Close(); _dbData = null; _dbe = null; }
/// <summary> /// Save table defintion to <paramref name="fileName"/> /// </summary> /// <param name="fileName">File name where save the table definition</param> public override void Save(string fileName) { MakePath(System.IO.Path.GetDirectoryName(fileName)); dao.DBEngine dbEngine = new dao.DBEngine(); dao.Database db = dbEngine.OpenDatabase(App.FileName); dao.TableDef tbDef = db.TableDefs[Name]; using (StreamWriter sw = new StreamWriter(fileName)) { ExportObject export = new ExportObject(sw); //export.ListProperties(tbDef.Name, tbDef.Properties); export.WriteBegin(ClassName, TableName); export.WriteProperty("Attributes", tbDef.Attributes); export.WriteProperty("Connect", tbDef.Connect); export.WriteProperty("SourceTableName", tbDef.SourceTableName); export.WriteProperty("ValidationRule", tbDef.ValidationRule); export.WriteProperty("ValidationText", tbDef.ValidationText); PropertyCollectionDao propColl = new PropertyCollectionDao(tbDef, tbDef.Properties); propColl.TryWriteProperty(export, "Description"); propColl.TryWriteProperty(export, "ConflictTable"); propColl.TryWriteProperty(export, "ReplicaFilter"); propColl.TryWriteProperty(export, "Orientation"); propColl.TryWriteProperty(export, "OrderByOn"); propColl.TryWriteProperty(export, "SubdatasheetName"); propColl.TryWriteProperty(export, "LinkChildFields"); propColl.TryWriteProperty(export, "LinkMasterFields"); propColl.TryWriteProperty(export, "SubdatasheetHeight"); propColl.TryWriteProperty(export, "SubdatasheetExpanded"); propColl.TryWriteProperty(export, "DefaultView"); propColl.TryWriteProperty(export, "OrderBy"); export.WriteBegin("Fields"); foreach (dao.Field field in tbDef.Fields) { export.WriteObject(new Field(field)); } export.WriteEnd(); //End Fields export.WriteBegin("Indexes"); //TODO: Add new option menu to ignore linked tables errors if the linked document do not exist // Check if the linked document exists before iterate the indexes collection foreach (dao.Index daoIndex in tbDef.Indexes) { export.WriteObject(new Index(daoIndex)); } export.WriteEnd(); //End Indexes export.WriteEnd(); //End Table } db.Close(); }
public static void Main(string[] args) { try { if (args.Length == 0) { Console.WriteLine("Please enter an MSAccess application path as a parameter!"); Console.WriteLine(); Console.WriteLine("Press enter to continue ..."); Console.ReadLine(); return; } dbEngine = new DAO.DBEngine(); database = dbEngine.OpenDatabase(args[0]); DAO.Property allowBypassKeyProperty = null; foreach (dao.Property property in database.Properties) { if (property.Name == "AllowBypassKey") { allowBypassKeyProperty = property; break; } } if (allowBypassKeyProperty == null) { allowBypassKeyProperty = database.CreateProperty("AllowBypassKey", DAO.DataTypeEnum.dbBoolean, false, true); database.Properties.Append(allowBypassKeyProperty); Console.WriteLine("AllowBypassKey Property has been added."); } else { allowBypassKeyProperty.Value = !allowBypassKeyProperty.Value; Console.WriteLine("AllowBypassKey is now " + allowBypassKeyProperty.Value + "!"); } } finally { database.Close(); System.Runtime.InteropServices.Marshal.ReleaseComObject(database); database = null; System.Runtime.InteropServices.Marshal.ReleaseComObject(dbEngine); dbEngine = null; } }