public bool HasProperty(string propertyName) { try { dao.Property property = Properties[propertyName]; return(true); } catch { return(false); } }
public bool PropertyHasValue(dao.Property property) { try { object dummy = property.Value; return(true); } catch { return(false); } }
/// <summary> /// Write a property name and its value /// </summary> /// <param name="propertyName">name of the property</param> /// <param name="value"><see cref="dao.Property"/> property</param> public void WriteProperty(string propertyName, dao.Property value) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}{1}:", new String(' ', Indent * TabSize), propertyName); if (value != null && value.Value != null) { sb.AppendFormat(" {0}", Convert.ToString(value, System.Globalization.CultureInfo.InvariantCulture)); } sw.WriteLine(sb.ToString()); }
internal void ListProperties(string objectName, dao.Properties properties) { System.Diagnostics.Debug.WriteLine(objectName); for (int i = 1; i < properties.Count; i++) { dao.Property property = properties[i]; object value = null; try { value = property.Value; } catch { value = "#Error"; } System.Diagnostics.Debug.WriteLine(String.Format("\t{0}:\t{1}", property.Name, value)); } }
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; } }