Click or drag to resize

ConnectorDataItemClassSetDB Method

Sets database

Namespace:  SOWIData.Database
Assembly:  SOWIData (in SOWIData.dll) Version: 19.1.23.1 (19.1.23.622)
Syntax
protected abstract void SetDB()
Examples
This example standard set database
/// <summary>
/// Set database
/// </summary>
protected override void SetDB()
{
    try
    {
        this.DB = new SOWIData.Management.Database.Tables(this.ConnectionString);
        if (!this.DB.Database.Exists()) { throw new Exception("database not exists!"); }
    }
    catch (Exception ex)
    {
        SIC.Protocol.Write(ref ex);
        throw ex;
    }
}
This example standard set XML file
/// <summary>
/// Puts XML data connector via property ConnectionString
/// </summary>
/// <remarks>
/// For a XML data connector must the property value DataSource of ConnectionString equal XML (see <see cref="SOWIData.Providers"/>. <para/>
/// Then is property value InitialCatalog the XML file name.
/// </remarks>
/// <seealso cref="SOWIData.Providers"/>
/// <seealso cref="SqlConnectionStringBuilder"/>
protected override void SetDB()
{
    try
    {
        //* analysis of property ConnectionString *
        SqlConnectionStringBuilder lConnectionString = new SqlConnectionStringBuilder(this.ConnectionString);
        string lDataSource = lConnectionString.DataSource;
        if (lDataSource.ToUpper() == SOWIData.Providers.XML.ToString())
        {
            //* puts XML data connector *
            string lFileName = lConnectionString.InitialCatalog;
            this.XML = new SOWIData.XML.Document<SOWIData.Test.TestObject.SOWIDataStandard>(lFileName);
        }
    }
    catch (Exception ex)
    {
        SIC.Protocol.Write(ref ex);
        throw ex;
    }
}
See Also