public static void AdjustForDynamicLoad(string DatabaseName, string Host) { if (theObjectScopeProvider1 == null) theObjectScopeProvider1 = new ObjectScopeProvider1(); if (theObjectScopeProvider1.myDatabase == null) { string assumedInitialConfiguration = "<openaccess>" + "<references>" + "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" + "</references>" + "<connections>" + @"<connection id=""DatabaseConnection2"">" + "<databasename>" + DatabaseName + "</databasename>" + @"<servername>" + Host + "</servername>" + "<integratedSecurity>True</integratedSecurity>" + "<backendconfigurationname>mssqlConfiguration</backendconfigurationname>" + "</connection>" + "</connections>" + "</openaccess>"; System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly; assumedInitialConfiguration = assumedInitialConfiguration.Replace( "PLACEHOLDER", dll.GetName().Name); var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(assumedInitialConfiguration); Database db = Telerik.OpenAccess.Database.Get("DatabaseConnection2", xmlDoc.DocumentElement, new[] { dll }); theObjectScopeProvider1.myDatabase = db; } }
/// <summary> /// Adjusts for dynamic loading when no entry assembly is available/configurable. /// </summary> /// <remarks> /// When dynamic loading is used, the configuration path from the /// applications entry assembly to the connection setting might be broken. /// This method makes up the necessary configuration entries. /// </remarks> public static void AdjustForDynamicLoad() { if (theObjectScopeProvider1 == null) theObjectScopeProvider1 = new ObjectScopeProvider1(); if (theObjectScopeProvider1.myDatabase == null) { string assumedInitialConfiguration = "<openaccess>" + "<references>" + "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" + "</references>" + "</openaccess>"; System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly; assumedInitialConfiguration = assumedInitialConfiguration.Replace( "PLACEHOLDER", dll.GetName().Name); var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(assumedInitialConfiguration); Database db = Telerik.OpenAccess.Database.Get("DatabaseConnection1", xmlDoc.DocumentElement, new[] { dll }); theObjectScopeProvider1.myDatabase = db; } }
/// <summary> /// Adjusts for dynamic loading when no entry assembly is available/configurable. /// </summary> /// <remarks> /// When dynamic loading is used, the configuration path from the /// applications entry assembly to the connection setting might be broken. /// This method makes up the necessary configuration entries. /// </remarks> static public void AdjustForDynamicLoad() { if (theObjectScopeProvider1 == null) { theObjectScopeProvider1 = new ObjectScopeProvider1(); } if (theObjectScopeProvider1.myDatabase == null) { string assumedInitialConfiguration = "<openaccess>" + "<references>" + "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" + "</references>" + "</openaccess>"; System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly; assumedInitialConfiguration = assumedInitialConfiguration.Replace( "PLACEHOLDER", dll.GetName().Name); var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(assumedInitialConfiguration); Database db = Telerik.OpenAccess.Database.Get("DatabaseConnection1", xmlDoc.DocumentElement, new[] { dll }); theObjectScopeProvider1.myDatabase = db; } }
/// <summary> /// Returns the instance of Database for the connectionId /// specified in the Enable Project Wizard. /// </summary> /// <returns>Instance of Database.</returns> /// <remarks></remarks> public static Database Database() { if (theObjectScopeProvider1 == null) theObjectScopeProvider1 = new ObjectScopeProvider1(); if (theObjectScopeProvider1.myDatabase == null) { theObjectScopeProvider1.myDatabase = Telerik.OpenAccess.Database.Get("DatabaseConnection1"); } return theObjectScopeProvider1.myDatabase; }