当前位置: 首页>>代码示例>>C#>>正文


C# SqlClient.SqlConnectionString类代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlConnectionString的典型用法代码示例。如果您正苦于以下问题:C# SqlConnectionString类的具体用法?C# SqlConnectionString怎么用?C# SqlConnectionString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlConnectionString类属于System.Data.SqlClient命名空间,在下文中一共展示了SqlConnectionString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFailoverPermission

        private System.Security.PermissionSet CreateFailoverPermission(SqlConnectionString userConnectionOptions, string actualFailoverPartner) {
            string keywordToReplace;

            // RULES FOR CONSTRUCTING THE CONNECTION STRING TO DEMAND ON:
            //
            // 1) If no Failover Partner was specified in the original string:
            //
            //          Server=actualFailoverPartner
            //
            // 2) If Failover Partner was specified in the original string:
            //
            //          Server=originalValue; Failover Partner=actualFailoverPartner
            //
            // NOTE: in all cases, when we get a failover partner name from 
            //       the server, we will use that name over what was specified  
            //       in the original connection string.
            
            if (null == userConnectionOptions[SqlConnectionString.KEY.FailoverPartner]) {
                keywordToReplace = SqlConnectionString.KEY.Data_Source;
            }
            else {
                keywordToReplace = SqlConnectionString.KEY.FailoverPartner;
            }
            
            string failoverConnectionString = userConnectionOptions.ExpandKeyword(keywordToReplace, actualFailoverPartner);
            return (new SqlConnectionString(failoverConnectionString)).CreatePermissionSet();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:SqlConnectionPoolGroupProviderInfo.cs

示例2: ServerInfo

 internal ServerInfo(SqlConnectionString userOptions, string serverName)
 {
     this.UserServerName = serverName ?? string.Empty;
     this.UserProtocol = userOptions.NetworkLibrary;
     this.ResolvedDatabaseName = userOptions.InitialCatalog;
     this.PreRoutingServerName = null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:ServerInfo.cs

示例3: SqlClientPermission

 internal SqlClientPermission(SqlConnectionString constr) : base(constr)
 {
     if ((constr == null) || constr.IsEmpty)
     {
         base.Add(ADP.StrEmpty, ADP.StrEmpty, KeyRestrictionBehavior.AllowOnly);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:SqlClientPermission.cs

示例4: SqlConnectionPoolGroupProviderInfo

 internal SqlConnectionPoolGroupProviderInfo(SqlConnectionString connectionOptions)
 {
     this._failoverPartner = connectionOptions.FailoverPartner;
     if (ADP.IsEmpty(this._failoverPartner))
     {
         this._failoverPartner = null;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SqlConnectionPoolGroupProviderInfo.cs

示例5: SqlConnectionPoolGroupProviderInfo

        internal SqlConnectionPoolGroupProviderInfo(SqlConnectionString connectionOptions) {
            // This is for the case where the user specified the failover partner
            // in the connection string and we have not yet connected to get the 
            // env change.
            _failoverPartner = connectionOptions.FailoverPartner;

            if (ADP.IsEmpty(_failoverPartner)) {
                _failoverPartner = null;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:SqlConnectionPoolGroupProviderInfo.cs

示例6: SqlInternalConnectionSmi

 internal SqlInternalConnectionSmi(SqlConnectionString connectionOptions, SmiContext smiContext) : base(connectionOptions)
 {
     this._smiContext = smiContext;
     this._smiContext.OutOfScope += new EventHandler(this.OnOutOfScope);
     this._smiConnection = this._smiContext.ContextConnection;
     this._smiEventSink = new EventSink(this);
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<sc.SqlInternalConnectionSmi.ctor|ADV> %d#, constructed new SMI internal connection\n", base.ObjectID);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:SqlInternalConnectionSmi.cs

示例7: CreateFailoverPermission

 private PermissionSet CreateFailoverPermission(SqlConnectionString userConnectionOptions, string actualFailoverPartner)
 {
     string str;
     if (userConnectionOptions["failover partner"] == null)
     {
         str = "data source";
     }
     else
     {
         str = "failover partner";
     }
     return new SqlConnectionString(userConnectionOptions.ExpandKeyword(str, actualFailoverPartner)).CreatePermissionSet();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:SqlConnectionPoolGroupProviderInfo.cs

示例8: SqlInternalConnectionTds

 internal SqlInternalConnectionTds(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, object providerInfo, string newPassword, SqlConnection owningObject, bool redirectedUserInstance) : base(connectionOptions)
 {
     this._instanceName = string.Empty;
     if (connectionOptions.UserInstance && InOutOfProcHelper.InProc)
     {
         throw SQL.UserInstanceNotAvailableInProc();
     }
     this._identity = identity;
     this._poolGroupProviderInfo = (SqlConnectionPoolGroupProviderInfo) providerInfo;
     this._fResetConnection = connectionOptions.ConnectionReset;
     if (this._fResetConnection)
     {
         this._originalDatabase = connectionOptions.InitialCatalog;
         this._originalLanguage = connectionOptions.CurrentLanguage;
     }
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         TimeoutTimer timeout = TimeoutTimer.StartSecondsTimeout(connectionOptions.ConnectTimeout);
         this.OpenLoginEnlist(owningObject, timeout, connectionOptions, newPassword, redirectedUserInstance);
     }
     catch (OutOfMemoryException)
     {
         base.DoomThisConnection();
         throw;
     }
     catch (StackOverflowException)
     {
         base.DoomThisConnection();
         throw;
     }
     catch (ThreadAbortException)
     {
         base.DoomThisConnection();
         throw;
     }
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<sc.SqlInternalConnectionTds.ctor|ADV> %d#, constructed new TDS internal connection\n", base.ObjectID);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:41,代码来源:SqlInternalConnectionTds.cs

示例9: FailoverCheck

 internal void FailoverCheck(SqlInternalConnection connection, bool actualUseFailoverPartner, SqlConnectionString userConnectionOptions, string actualFailoverPartner)
 {
     if (this.UseFailoverPartner != actualUseFailoverPartner)
     {
         Bid.Trace("<sc.SqlConnectionPoolGroupProviderInfo|INFO> Failover detected. failover partner='%ls'. Clearing PoolGroup\n", actualFailoverPartner);
         base.PoolGroup.Clear();
         this._useFailoverPartner = actualUseFailoverPartner;
     }
     if (!this._useFailoverPartner && (this._failoverPartner != actualFailoverPartner))
     {
         PermissionSet set = this.CreateFailoverPermission(userConnectionOptions, actualFailoverPartner);
         lock (this)
         {
             if (this._failoverPartner != actualFailoverPartner)
             {
                 this._failoverPartner = actualFailoverPartner;
                 this._failoverPermissionSet = set;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:SqlConnectionPoolGroupProviderInfo.cs

示例10: FailoverCheck

        internal void FailoverCheck(SqlInternalConnection connection, bool actualUseFailoverPartner, SqlConnectionString userConnectionOptions, string actualFailoverPartner)
        {
            if (UseFailoverPartner != actualUseFailoverPartner)
            {
                base.PoolGroup.Clear();
                _useFailoverPartner = actualUseFailoverPartner;
            }
            // Only construct a new permission set when we're connecting to the
            // primary data source, not the failover partner.
            if (!_useFailoverPartner && _failoverPartner != actualFailoverPartner)
            {
                // NOTE: we optimisitically generate the permission set to keep 
                //       lock short, but we only do this when we get a new
                //       failover partner.

                lock (this)
                {
                    if (_failoverPartner != actualFailoverPartner)
                    {
                        _failoverPartner = actualFailoverPartner;
                    }
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:24,代码来源:SqlConnectionPoolGroupProviderInfo.cs

示例11: FindSqlConnectionOptions

 internal static SqlConnectionString FindSqlConnectionOptions(SqlConnectionPoolKey key) {
     SqlConnectionString connectionOptions = (SqlConnectionString )SingletonInstance.FindConnectionOptions(key);
     if (null == connectionOptions) {
         connectionOptions = new SqlConnectionString(key.ConnectionString);
     }
     if (connectionOptions.IsEmpty) {
         throw ADP.NoConnectionString();
     }
     return connectionOptions;
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:SqlConnectionFactory.cs

示例12: CreateConnectionOptions

 protected override DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous) {
     Debug.Assert(!ADP.IsEmpty(connectionString), "empty connectionString");
     SqlConnectionString result = new SqlConnectionString(connectionString);
     return result;
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:5,代码来源:SqlConnectionFactory.cs

示例13: SqlInternalConnectionTds

        // although the new password is generally not used it must be passed to the c'tor
        // the new Login7 packet will always write out the new password (or a length of zero and no bytes if not present)
        //
        internal SqlInternalConnectionTds(
                DbConnectionPoolIdentity    identity, 
                SqlConnectionString         connectionOptions,
                SqlCredential               credential,
                object                      providerInfo, 
                string                      newPassword,
                SecureString                newSecurePassword,
                bool                        redirectedUserInstance,
                SqlConnectionString         userConnectionOptions = null, // NOTE: userConnectionOptions may be different to connectionOptions if the connection string has been expanded (see SqlConnectionString.Expand)
                SessionData                 reconnectSessionData = null,
                DbConnectionPool            pool = null,
                string                      accessToken = null,
                bool applyTransientFaultHandling = false
                ) : base(connectionOptions) {

#if DEBUG
            if (reconnectSessionData != null) {
                reconnectSessionData._debugReconnectDataApplied = true;
            }
            try { // use this to help validate this object is only created after the following permission has been previously demanded in the current codepath
                if (userConnectionOptions != null) {
                    // As mentioned above, userConnectionOptions may be different to connectionOptions, so we need to demand on the correct connection string
                    userConnectionOptions.DemandPermission();
                }
                else {
                    connectionOptions.DemandPermission();
                }
            }
            catch(System.Security.SecurityException) {
                System.Diagnostics.Debug.Assert(false, "unexpected SecurityException for current codepath");
                throw;
            }
#endif
            Debug.Assert(reconnectSessionData == null || connectionOptions.ConnectRetryCount > 0, "Reconnect data supplied with CR turned off");

            _dbConnectionPool = pool;
  
            if (connectionOptions.ConnectRetryCount > 0) {
                _recoverySessionData = reconnectSessionData;          
                if (reconnectSessionData == null) {
                    _currentSessionData = new SessionData();
                }
                else {
                    _currentSessionData = new SessionData(_recoverySessionData);
                    _originalDatabase = _recoverySessionData._initialDatabase;
                    _originalLanguage = _recoverySessionData._initialLanguage;
                }
            }
          
            if (connectionOptions.UserInstance && InOutOfProcHelper.InProc) {
                throw SQL.UserInstanceNotAvailableInProc();
            }

            if (accessToken != null) {
                _accessTokenInBytes = System.Text.Encoding.Unicode.GetBytes(accessToken);
            }

            _identity = identity;
            Debug.Assert(newSecurePassword != null || newPassword != null, "cannot have both new secure change password and string based change password to be null");
            Debug.Assert(credential == null || (String.IsNullOrEmpty(connectionOptions.UserID) && String.IsNullOrEmpty(connectionOptions.Password)), "cannot mix the new secure password system and the connection string based password");

            Debug.Assert(credential == null || !connectionOptions.IntegratedSecurity, "Cannot use SqlCredential and Integrated Security");
            Debug.Assert(credential == null || !connectionOptions.ContextConnection, "Cannot use SqlCredential with context connection");

            _poolGroupProviderInfo = (SqlConnectionPoolGroupProviderInfo)providerInfo;
            _fResetConnection = connectionOptions.ConnectionReset;
            if (_fResetConnection && _recoverySessionData == null) {
                _originalDatabase = connectionOptions.InitialCatalog;
                _originalLanguage = connectionOptions.CurrentLanguage;
            }

            timeoutErrorInternal = new SqlConnectionTimeoutErrorInternal();
            _credential = credential;

            _parserLock.Wait(canReleaseFromAnyThread:false);
            ThreadHasParserLockForClose = true;   // In case of error, let ourselves know that we already own the parser lock
            RuntimeHelpers.PrepareConstrainedRegions();
            try {
#if DEBUG
                TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();

                RuntimeHelpers.PrepareConstrainedRegions();
                try {
                    tdsReliabilitySection.Start();
#else
                {
#endif //DEBUG
                    _timeout = TimeoutTimer.StartSecondsTimeout(connectionOptions.ConnectTimeout);

                    // If transient fault handling is enabled then we can retry the login upto the ConnectRetryCount.
                    int connectionEstablishCount = applyTransientFaultHandling ? connectionOptions.ConnectRetryCount + 1 : 1;
                    int transientRetryIntervalInMilliSeconds = connectionOptions.ConnectRetryInterval * 1000; // Max value of transientRetryInterval is 60*1000 ms. The max value allowed for ConnectRetryInterval is 60
                    for (int i = 0; i < connectionEstablishCount; i++)
                    {
                        try
                        {
                            OpenLoginEnlist(_timeout, connectionOptions, credential, newPassword, newSecurePassword, redirectedUserInstance);
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SqlInternalConnectionTds.cs

示例14: ServerInfo

        // Initialize server info from connection options, but override DataSource with given server name
        internal ServerInfo(SqlConnectionString userOptions, RoutingInfo routing, string preRoutingServerName) {
            //-----------------
            // Preconditions
            Debug.Assert(null != userOptions && null!=routing);

            //-----------------
            //Method body
            Debug.Assert(routing.ServerName != null, "server name should never be null");
            if (routing == null || routing.ServerName == null) {
                UserServerName = string.Empty; // ensure user server name is not null
            }
            else {
                UserServerName = string.Format(CultureInfo.InvariantCulture, "{0},{1}", routing.ServerName, routing.Port);
            }
            PreRoutingServerName = preRoutingServerName;
            UserProtocol = TdsEnums.TCP;
            SetDerivedNames(UserProtocol, UserServerName);
            ResolvedDatabaseName = userOptions.InitialCatalog;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:20,代码来源:SqlInternalConnectionTds.cs

示例15: SqlInternalConnection

 internal SqlInternalConnection(SqlConnectionString connectionOptions) : base()
 {
     Debug.Assert(null != connectionOptions, "null connectionOptions?");
     _connectionOptions = connectionOptions;
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:5,代码来源:SqlInternalConnection.cs


注:本文中的System.Data.SqlClient.SqlConnectionString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。