/// <summary> /// Attempts to establish a connection to the data source, using connection settings /// generated by a call to UpdateConnectionSettings(). /// </summary> /// <param name="connectionSettings">Connection settings used to authenticate the connection.</param> public override void Connect(Dictionary <string, object> connectionSettings) { // TODO(ODBC) #04: Establish a connection. // TODO(ADO) #06: Establish a connection. LogUtilities.LogFunctionEntrance(Log, connectionSettings); Utilities.NullCheck("connectionSettings", connectionSettings); // The SimbaEngine SDK will call UpdateConnectionSettings() prior to calling this method. // This will ensure that all valid keys required to create a connection have been specified // and are stored within in_connectionSettings. // // This method should validate each of the incoming values and throw an error in the event // of an invalid value. // This driver doesn't validate the given settings, it just requires them. string server = GetRequiredSetting(Driver.B_SERVER_KEY, connectionSettings).ToString(); string uid = GetRequiredSetting(Driver.B_UID_KEY, connectionSettings).ToString(); string pwd = GetRequiredSetting(Driver.B_PWD_KEY, connectionSettings).ToString(); string catalog = GetRequiredSetting(Driver.B_CATALOG_KEY, connectionSettings).ToString(); string strRows = GetRequiredSetting(Driver.B_ROWS_TO_FETCH_KEY, connectionSettings).ToString(); int rows = 1000; Int32.TryParse(strRows, out rows); object objResultType; BProperties.ResultTypes result_type = BProperties.ResultTypes.Normal; GetOptionalSetting(Driver.B_RESULT_TYPE_KEY, connectionSettings, out objResultType); if (objResultType == null) { Enum.TryParse <BProperties.ResultTypes>(objResultType.ToString(), true, out result_type); } if (string.IsNullOrWhiteSpace(uid) || string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(catalog) || string.IsNullOrWhiteSpace(server)) { throw new Exception("required parameters were not supplied or invalid"); } SetProperty(ConnectionPropertyKey.DSI_CONN_SERVER_NAME, server); SetProperty(ConnectionPropertyKey.DSI_CONN_CURRENT_CATALOG, catalog); SetProperty(ConnectionPropertyKey.DSI_CONN_USER_NAME, uid); m_Properties = new BProperties() { Server = server, UserName = uid, Password = pwd, Catalog = catalog, RowsToFetch = rows, ResultType = result_type }; }
/// <summary> /// Attempts to establish a connection to the data source, using connection settings /// generated by a call to UpdateConnectionSettings(). /// </summary> /// <param name="connectionSettings">Connection settings used to authenticate the connection.</param> public override void Connect(Dictionary<string, object> connectionSettings) { // TODO(ODBC) #04: Establish a connection. // TODO(ADO) #06: Establish a connection. LogUtilities.LogFunctionEntrance(Log, connectionSettings); Utilities.NullCheck("connectionSettings", connectionSettings); // The SimbaEngine SDK will call UpdateConnectionSettings() prior to calling this method. // This will ensure that all valid keys required to create a connection have been specified // and are stored within in_connectionSettings. // // This method should validate each of the incoming values and throw an error in the event // of an invalid value. // This driver doesn't validate the given settings, it just requires them. string server = GetRequiredSetting(Driver.B_SERVER_KEY, connectionSettings).ToString(); string uid = GetRequiredSetting(Driver.B_UID_KEY, connectionSettings).ToString(); string pwd = GetRequiredSetting(Driver.B_PWD_KEY, connectionSettings).ToString(); string catalog = GetRequiredSetting(Driver.B_CATALOG_KEY, connectionSettings).ToString(); string strRows = GetRequiredSetting(Driver.B_ROWS_TO_FETCH_KEY, connectionSettings).ToString(); int rows = 1000; Int32.TryParse(strRows, out rows); object objResultType; BProperties.ResultTypes result_type = BProperties.ResultTypes.Normal; GetOptionalSetting(Driver.B_RESULT_TYPE_KEY, connectionSettings, out objResultType); if (objResultType == null) { Enum.TryParse<BProperties.ResultTypes>(objResultType.ToString(), true, out result_type); } if (string.IsNullOrWhiteSpace(uid) || string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(catalog) || string.IsNullOrWhiteSpace(server)) { throw new Exception("required parameters were not supplied or invalid"); } SetProperty(ConnectionPropertyKey.DSI_CONN_SERVER_NAME, server); SetProperty(ConnectionPropertyKey.DSI_CONN_CURRENT_CATALOG, catalog); SetProperty(ConnectionPropertyKey.DSI_CONN_USER_NAME, uid); m_Properties = new BProperties() { Server = server, UserName = uid, Password = pwd, Catalog = catalog, RowsToFetch = rows, ResultType = result_type }; }
/// <summary> /// Constructor. /// </summary> /// <param name="connection">The parent connection.</param> public BStatement(BConnection connection, BProperties properties) : base(connection) { LogUtilities.LogFunctionEntrance(Connection.Log, connection); m_Properties = properties; }