Site icon BITtelligent Software and Media

Testing for a Remote SalesLogix Client Web Site

A question was posted on the Sage newsgroups for determining if the web site is connected to either a remote or office database. I gave it some quick thought and felt the best test would be to determine the database that the site was connected to. To solve this problem I wrote the following code;

 

public bool IsRemote()
{
    bool result = false;
    Sage.Platform.Data.IDataService service = ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>();
    if (service != null)
    {
        System.Data.OleDb.OleDbConnectionStringBuilder builder = new System.Data.OleDb.OleDbConnectionStringBuilder(service.GetConnectionString());
        string databaseName = (string)builder[“Initial Catalog”];

        if (“slxremote”.Equals(databaseName, StringComparison.InvariantCultureIgnoreCase))
            result = true;
    }

    return result;
}

 

Enjoy!

Mark

Exit mobile version