Exemple #1
0
 internal static Exception TimeScaleValueOutOfRange(byte scale)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_TimeScaleValueOutOfRange, scale.ToString(CultureInfo.InvariantCulture))));
 }
Exemple #2
0
 internal static Exception UnknownSQLType(ODBC32.SQL_TYPE sqltype)
 {
     return(ADP.Argument(SR.GetString(SR.Odbc_UnknownSQLType, sqltype.ToString())));
 }
Exemple #3
0
 internal static ArgumentException GetSchemaRestrictionRequired()
 {
     return(ADP.Argument(SR.GetString(SR.ODBC_GetSchemaRestrictionRequired)));
 }
Exemple #4
0
 internal static ArgumentException Fill_EmptyRecord(string parameter, Exception innerException)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_Fill_EmptyRecord), parameter, innerException));
 }
Exemple #5
0
        internal static bool Start(string connectionString, string queue, bool useDefaults)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                if (null == connectionString)
                {
                    throw ADP.ArgumentNull(nameof(connectionString));
                }
                else
                {
                    throw ADP.Argument(nameof(connectionString));
                }
            }

            if (!useDefaults && string.IsNullOrEmpty(queue))
            {                       // If specified but null or empty, use defaults.
                useDefaults = true;
                queue       = null; // Force to null - for proper hashtable comparison for default case.
            }

            // End duplicate Start/Stop logic.

            bool errorOccurred = false;
            bool result        = false;

            lock (s_startStopLock)
            {
                try
                {
                    if (null == s_processDispatcher)
                    { // Ensure _processDispatcher reference is present - inside lock.
                        s_processDispatcher = SqlDependencyProcessDispatcher.SingletonProcessDispatcher;
                    }

                    if (useDefaults)
                    { // Default listener.
                        string server = null;
                        DbConnectionPoolIdentity identity = null;
                        string user           = null;
                        string database       = null;
                        string service        = null;
                        bool   appDomainStart = false;

                        RuntimeHelpers.PrepareConstrainedRegions();
                        try
                        { // CER to ensure that if Start succeeds we add to hash completing setup.
                            // Start using process wide default service/queue & database from connection string.
                            result = s_processDispatcher.StartWithDefault(
                                connectionString,
                                out server,
                                out identity,
                                out user,
                                out database,
                                ref service,
                                s_appDomainKey,
                                SqlDependencyPerAppDomainDispatcher.SingletonInstance,
                                out errorOccurred,
                                out appDomainStart);
                        }
                        finally
                        {
                            if (appDomainStart && !errorOccurred)
                            { // If success, add to hashtable.
                                IdentityUserNamePair identityUser    = new IdentityUserNamePair(identity, user);
                                DatabaseServicePair  databaseService = new DatabaseServicePair(database, service);
                                if (!AddToServerUserHash(server, identityUser, databaseService))
                                {
                                    try
                                    {
                                        Stop(connectionString, queue, useDefaults, true);
                                    }
                                    catch (Exception e)
                                    { // Discard stop failure!
                                        if (!ADP.IsCatchableExceptionType(e))
                                        {
                                            throw;
                                        }

                                        ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now.
                                    }
                                    throw SQL.SqlDependencyDuplicateStart();
                                }
                            }
                        }
                    }
                    else
                    { // Start with specified service/queue & database.
                        result = s_processDispatcher.Start(
                            connectionString,
                            queue,
                            s_appDomainKey,
                            SqlDependencyPerAppDomainDispatcher.SingletonInstance);
                        // No need to call AddToServerDatabaseHash since if not using default queue user is required
                        // to provide options themselves.
                    }
                }
                catch (Exception e)
                {
                    if (!ADP.IsCatchableExceptionType(e))
                    {
                        throw;
                    }

                    ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now.

                    throw;
                }
            }

            return(result);
        }
Exemple #6
0
 internal static ArgumentException InvalidRestrictionsDbInfoLiteral(string parameter)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_InvalidRestrictionsDbInfoLiteral), parameter));
 }
Exemple #7
0
 internal static ArgumentException NotSupportedSchemaTable(Guid schema, OleDbConnection connection)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_NotSupportedSchemaTable, OleDbSchemaGuid.GetTextFromValue(schema), connection.Provider)));
 }
Exemple #8
0
 internal static Exception UnsupportedColumnTypeForSqlProvider(string columnName, string typeName)
 {
     return(ADP.Argument(Res.GetString(Res.SqlProvider_InvalidDataColumnType, columnName, typeName)));
 }
Exemple #9
0
 internal static Exception NotEnoughColumnsInStructuredType()
 {
     return(ADP.Argument(Res.GetString(Res.SqlProvider_NotEnoughColumnsInStructuredType)));
 }
Exemple #10
0
 internal static Exception InvalidSqlDbTypeForConstructor(SqlDbType type)
 {
     return(ADP.Argument(Res.GetString(Res.SqlMetaData_InvalidSqlDbTypeForConstructorFormat, type.ToString())));
 }
Exemple #11
0
 internal static Exception NameTooLong(string parameterName)
 {
     return(ADP.Argument(Res.GetString(Res.SqlMetaData_NameTooLong), parameterName));
 }
Exemple #12
0
 internal static Exception EnumeratedRecordFieldCountChanged(int recordNumber)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_EnumeratedRecordFieldCountChanged, recordNumber)));
 }
Exemple #13
0
 internal static Exception EnumeratedRecordMetaDataChanged(string fieldName, int recordNumber)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_EnumeratedRecordMetaDataChanged, fieldName, recordNumber)));
 }
Exemple #14
0
 internal static Exception MustSetTypeNameForParam(string paramType, string paramName)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_ParameterTypeNameRequired, paramType, paramName)));
 }
Exemple #15
0
 internal static ArgumentException AsynchronousNotSupported()
 {
     return(ADP.Argument(SR.Format(SR.OleDb_AsynchronousNotSupported)));
 }
Exemple #16
0
 internal static Exception IEnumerableOfSqlDataRecordHasNoRows()
 {
     return(ADP.Argument(Res.GetString(Res.IEnumerableOfSqlDataRecordHasNoRows)));
 }
Exemple #17
0
 internal static ArgumentException InvalidProviderSpecified()
 {
     return(ADP.Argument(SR.Format(SR.OleDb_InvalidProviderSpecified)));
 }
Exemple #18
0
 internal static Exception BulkLoadInvalidTimeout(int timeout)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_BulkLoadInvalidTimeout, timeout.ToString(CultureInfo.InvariantCulture))));
 }
Exemple #19
0
 internal static ArgumentException InvalidRestrictionsSchemaGuids(string parameter)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_InvalidRestrictionsSchemaGuids), parameter));
 }
Exemple #20
0
 internal static Exception BulkLoadConflictingTransactionOption()
 {
     return(ADP.Argument(Res.GetString(Res.SQL_BulkLoadConflictingTransactionOption)));
 }
Exemple #21
0
 // OleDbDataAdapter
 internal static ArgumentException Fill_NotADODB(string parameter)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_Fill_NotADODB), parameter));
 }
Exemple #22
0
        internal static Exception MultiSubnetFailoverWithNonTcpProtocol()
        {
            string msg = GetSNIErrorMessage((int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithNonTcpProtocol);

            return(ADP.Argument(msg));
        }
Exemple #23
0
 // OleDbEnumerator
 internal static ArgumentException ISourcesRowsetNotSupported()
 {
     throw ADP.Argument(SR.OleDb_ISourcesRowsetNotSupported);
 }
Exemple #24
0
        //
        // Read-only routing
        //

        internal static Exception ROR_FailoverNotSupportedConnString()
        {
            return(ADP.Argument(Res.GetString(Res.SQLROR_FailoverNotSupported)));
        }
Exemple #25
0
        internal static bool Stop(string connectionString, string queue, bool useDefaults, bool startFailed)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                if (null == connectionString)
                {
                    throw ADP.ArgumentNull(nameof(connectionString));
                }
                else
                {
                    throw ADP.Argument(nameof(connectionString));
                }
            }

            if (!useDefaults && string.IsNullOrEmpty(queue))
            {                       // If specified but null or empty, use defaults.
                useDefaults = true;
                queue       = null; // Force to null - for proper hashtable comparison for default case.
            }

            // End duplicate Start/Stop logic.

            bool result = false;

            lock (s_startStopLock)
            {
                if (null != s_processDispatcher)
                { // If _processDispatcher null, no Start has been called.
                    try
                    {
                        string server = null;
                        DbConnectionPoolIdentity identity = null;
                        string user     = null;
                        string database = null;
                        string service  = null;

                        if (useDefaults)
                        {
                            bool appDomainStop = false;

                            RuntimeHelpers.PrepareConstrainedRegions();
                            try
                            { // CER to ensure that if Stop succeeds we remove from hash completing teardown.
                                // Start using process wide default service/queue & database from connection string.
                                result = s_processDispatcher.Stop(
                                    connectionString,
                                    out server,
                                    out identity,
                                    out user,
                                    out database,
                                    ref service,
                                    s_appDomainKey,
                                    out appDomainStop);
                            }
                            finally
                            {
                                if (appDomainStop && !startFailed)
                                { // If success, remove from hashtable.
                                    Debug.Assert(!string.IsNullOrEmpty(server) && !string.IsNullOrEmpty(database), "Server or Database null/Empty upon successfull Stop()!");
                                    IdentityUserNamePair identityUser    = new IdentityUserNamePair(identity, user);
                                    DatabaseServicePair  databaseService = new DatabaseServicePair(database, service);
                                    RemoveFromServerUserHash(server, identityUser, databaseService);
                                }
                            }
                        }
                        else
                        {
                            result = s_processDispatcher.Stop(
                                connectionString,
                                out server,
                                out identity,
                                out user,
                                out database,
                                ref queue,
                                s_appDomainKey,
                                out bool ignored);
                            // No need to call RemoveFromServerDatabaseHash since if not using default queue user is required
                            // to provide options themselves.
                        }
                    }
                    catch (Exception e)
                    {
                        if (!ADP.IsCatchableExceptionType(e))
                        {
                            throw;
                        }

                        ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now.
                    }
                }
            }
            return(result);
        }
Exemple #26
0
 // OleDbConnection
 internal static ArgumentException SchemaRowsetsNotSupported(string provider)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_SchemaRowsetsNotSupported, "IDBSchemaRowset", provider)));
 }
Exemple #27
0
 internal static Exception ConnectionStringTooLong()
 {
     return(ADP.Argument(SR.GetString(SR.OdbcConnection_ConnectionStringTooLong, ODBC32.MAX_CONNECTION_STRING_LENGTH)));
 }
Exemple #28
0
 internal static ArgumentException MSDASQLNotSupported()
 {
     return(ADP.Argument(SR.Format(SR.OleDb_MSDASQLNotSupported)));
 }
Exemple #29
0
 internal static Exception NegativeArgument()
 {
     return(ADP.Argument(SR.GetString(SR.Odbc_NegativeArgument)));
 }
Exemple #30
0
 internal static Exception PrecisionValueOutOfRange(byte precision)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_PrecisionValueOutOfRange, precision.ToString(CultureInfo.InvariantCulture))));
 }