This question is locked. New answers and comments are not allowed.
I am using the AdjustForDynamicLoad Method and I modified it to pass in my connection settings.
static public void AdjustForDynamicLoad(string server, string dbname, string username, string password,bool integratedSecurity) |
{ |
//if (theObjectScopeProvider1 == null) |
theObjectScopeProvider1 = new ScopeProvider(); |
if (theObjectScopeProvider1.myDatabase == null) |
{ |
string assumedInitialConfiguration = |
"<openaccess>" + |
"<references>" + |
"<reference assemblyname='PLACEHOLDER' configrequired='True'/>" + |
"</references>" + |
"<connections>" + |
@"<connection id=""{0}"">" + |
"<databasename>{0}</databasename>" + |
@"<servername>{1}</servername>" + |
"<integratedSecurity>{4}</integratedSecurity>" + |
"{2}" + |
"{3}" + |
"<backendconfigurationname>mssqlConfiguration</backendconfigurationname>" + |
"</connection>" + |
"</connections>" + |
"</openaccess>"; |
string config = ""; |
if (integratedSecurity) |
{ |
config = string.Format(assumedInitialConfiguration, dbname,server, "", "", integratedSecurity.ToString()); |
} |
else |
{ |
config = string.Format(assumedInitialConfiguration, dbname,server, string.Format("<user>{0}</user>", username), string.Format("<password>{0}</password>", password), integratedSecurity.ToString()); |
} |
System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly; |
assumedInitialConfiguration = config.Replace( |
"PLACEHOLDER", dll.GetName().Name); |
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); |
xmlDoc.LoadXml(assumedInitialConfiguration); |
Database db = Telerik.OpenAccess.Database.Get(dbname, |
xmlDoc.DocumentElement, new System.Reflection.Assembly[] { dll }); |
theObjectScopeProvider1.myDatabase = db; |
} |
} |
The problem is we use this to point to the same database on several different servers. Is there a better way of changing the connection since if you use the same connection id Telerik.OpenAccess.Database.Get returns the initial database. I don't want to call it a bug but this doesn't seem like appropriate behavior. If I call Get and pass in a new xmlDoc then it should do the get on that xmldoc and not what's in memory.