示例#1
0
 internal static Exception TimeScaleValueOutOfRange(byte scale)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_TimeScaleValueOutOfRange, scale.ToString(CultureInfo.InvariantCulture))));
 }
示例#2
0
 internal static Exception UnknownSQLType(ODBC32.SQL_TYPE sqltype)
 {
     return(ADP.Argument(SR.GetString(SR.Odbc_UnknownSQLType, sqltype.ToString())));
 }
示例#3
0
 internal static ArgumentException GetSchemaRestrictionRequired()
 {
     return(ADP.Argument(SR.GetString(SR.ODBC_GetSchemaRestrictionRequired)));
 }
示例#4
0
 internal static ArgumentException Fill_EmptyRecord(string parameter, Exception innerException)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_Fill_EmptyRecord), parameter, innerException));
 }
示例#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);
        }
示例#6
0
 internal static ArgumentException InvalidRestrictionsDbInfoLiteral(string parameter)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_InvalidRestrictionsDbInfoLiteral), parameter));
 }
示例#7
0
 internal static ArgumentException NotSupportedSchemaTable(Guid schema, OleDbConnection connection)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_NotSupportedSchemaTable, OleDbSchemaGuid.GetTextFromValue(schema), connection.Provider)));
 }
示例#8
0
 internal static Exception UnsupportedColumnTypeForSqlProvider(string columnName, string typeName)
 {
     return(ADP.Argument(Res.GetString(Res.SqlProvider_InvalidDataColumnType, columnName, typeName)));
 }
示例#9
0
 internal static Exception NotEnoughColumnsInStructuredType()
 {
     return(ADP.Argument(Res.GetString(Res.SqlProvider_NotEnoughColumnsInStructuredType)));
 }
示例#10
0
 internal static Exception InvalidSqlDbTypeForConstructor(SqlDbType type)
 {
     return(ADP.Argument(Res.GetString(Res.SqlMetaData_InvalidSqlDbTypeForConstructorFormat, type.ToString())));
 }
示例#11
0
 internal static Exception NameTooLong(string parameterName)
 {
     return(ADP.Argument(Res.GetString(Res.SqlMetaData_NameTooLong), parameterName));
 }
示例#12
0
 internal static Exception EnumeratedRecordFieldCountChanged(int recordNumber)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_EnumeratedRecordFieldCountChanged, recordNumber)));
 }
示例#13
0
 internal static Exception EnumeratedRecordMetaDataChanged(string fieldName, int recordNumber)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_EnumeratedRecordMetaDataChanged, fieldName, recordNumber)));
 }
示例#14
0
 internal static Exception MustSetTypeNameForParam(string paramType, string paramName)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_ParameterTypeNameRequired, paramType, paramName)));
 }
示例#15
0
 internal static ArgumentException AsynchronousNotSupported()
 {
     return(ADP.Argument(SR.Format(SR.OleDb_AsynchronousNotSupported)));
 }
示例#16
0
 internal static Exception IEnumerableOfSqlDataRecordHasNoRows()
 {
     return(ADP.Argument(Res.GetString(Res.IEnumerableOfSqlDataRecordHasNoRows)));
 }
示例#17
0
 internal static ArgumentException InvalidProviderSpecified()
 {
     return(ADP.Argument(SR.Format(SR.OleDb_InvalidProviderSpecified)));
 }
示例#18
0
 internal static Exception BulkLoadInvalidTimeout(int timeout)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_BulkLoadInvalidTimeout, timeout.ToString(CultureInfo.InvariantCulture))));
 }
示例#19
0
 internal static ArgumentException InvalidRestrictionsSchemaGuids(string parameter)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_InvalidRestrictionsSchemaGuids), parameter));
 }
示例#20
0
 internal static Exception BulkLoadConflictingTransactionOption()
 {
     return(ADP.Argument(Res.GetString(Res.SQL_BulkLoadConflictingTransactionOption)));
 }
示例#21
0
 // OleDbDataAdapter
 internal static ArgumentException Fill_NotADODB(string parameter)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_Fill_NotADODB), parameter));
 }
示例#22
0
        internal static Exception MultiSubnetFailoverWithNonTcpProtocol()
        {
            string msg = GetSNIErrorMessage((int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithNonTcpProtocol);

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

        internal static Exception ROR_FailoverNotSupportedConnString()
        {
            return(ADP.Argument(Res.GetString(Res.SQLROR_FailoverNotSupported)));
        }
示例#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);
        }
示例#26
0
 // OleDbConnection
 internal static ArgumentException SchemaRowsetsNotSupported(string provider)
 {
     return(ADP.Argument(SR.Format(SR.OleDb_SchemaRowsetsNotSupported, "IDBSchemaRowset", provider)));
 }
示例#27
0
 internal static Exception ConnectionStringTooLong()
 {
     return(ADP.Argument(SR.GetString(SR.OdbcConnection_ConnectionStringTooLong, ODBC32.MAX_CONNECTION_STRING_LENGTH)));
 }
示例#28
0
 internal static ArgumentException MSDASQLNotSupported()
 {
     return(ADP.Argument(SR.Format(SR.OleDb_MSDASQLNotSupported)));
 }
示例#29
0
 internal static Exception NegativeArgument()
 {
     return(ADP.Argument(SR.GetString(SR.Odbc_NegativeArgument)));
 }
示例#30
0
 internal static Exception PrecisionValueOutOfRange(byte precision)
 {
     return(ADP.Argument(Res.GetString(Res.SQL_PrecisionValueOutOfRange, precision.ToString(CultureInfo.InvariantCulture))));
 }