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


C# SqlConnectionStringBuilder.Remove方法代码示例

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


在下文中一共展示了SqlConnectionStringBuilder.Remove方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SqlShardMapManagerCredentials

        /// <summary>
        /// Instantiates the object that holds the credentials for accessing SQL Servers 
        /// containing the shard map manager data.
        /// </summary>
        /// <param name="connectionString">Connection string for Shard map manager data source.</param>
        public SqlShardMapManagerCredentials(string connectionString)
        {
            ExceptionUtils.DisallowNullArgument(connectionString, "connectionString");

            // Devnote: If connection string specifies Active Directory authentication and runtime is not
            // .NET 4.6 or higher, then below call will throw.
            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(connectionString);

            #region GSM Validation

            // DataSource must be set.
            if (string.IsNullOrEmpty(connectionStringBuilder.DataSource))
            {
                throw new ArgumentException(
                    StringUtils.FormatInvariant(
                        Errors._SqlShardMapManagerCredentials_ConnectionStringPropertyRequired,
                        "DataSource"),
                    "connectionString");
            }

            // InitialCatalog must be set.
            if (string.IsNullOrEmpty(connectionStringBuilder.InitialCatalog))
            {
                throw new ArgumentException(
                    StringUtils.FormatInvariant(
                        Errors._SqlShardMapManagerCredentials_ConnectionStringPropertyRequired,
                        "Initial Catalog"),
                    "connectionString");
            }

            // Ensure credentials are specified for GSM connectivity.
            SqlShardMapManagerCredentials.EnsureCredentials(connectionStringBuilder, "connectionString");

            #endregion GSM Validation

            // Copy the input connection strings.
            _connectionStringShardMapManager = new SqlConnectionStringBuilder(connectionStringBuilder.ConnectionString);

            _connectionStringShardMapManager.ApplicationName = ApplicationNameHelper.AddApplicationNameSuffix(
                _connectionStringShardMapManager.ApplicationName,
                GlobalConstants.ShardMapManagerInternalConnectionSuffixGlobal);

            _connectionStringShard = new SqlConnectionStringBuilder(connectionStringBuilder.ConnectionString);

            _connectionStringShard.Remove("Data Source");
            _connectionStringShard.Remove("Initial Catalog");

            _connectionStringShard.ApplicationName = ApplicationNameHelper.AddApplicationNameSuffix(
                _connectionStringShard.ApplicationName,
                GlobalConstants.ShardMapManagerInternalConnectionSuffixLocal);
        }
开发者ID:jaredmoo,项目名称:elastic-db-tools,代码行数:56,代码来源:SqlShardMapManagerCredentials.cs

示例2: RemoveTest

		public void RemoveTest ()
		{
			builder = new SqlConnectionStringBuilder ("SERVER = localhost ;Network=DBMSSOCN");
			// non existing key
			Assert.AreEqual (false, builder.Remove ("ABCD"),
					 "#RT1 cannot remove non existant key");
			Assert.AreEqual (true, builder.Remove ("NETWORK library"),
					 "#RT2 should remove the key");
			Assert.AreEqual ("Data Source=localhost", builder.ConnectionString,
					 "#RT3 should have removed the key");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:SqlConnectionStringBuilderTest.cs

示例3: CreateAndStartProxy

        /// <summary>
        /// Creates a proxy server from the server in the given connection string using the default construction parameters and starts the proxy
        /// </summary>
        /// <param name="connectionString">Connection string to the server to proxy</param>
        /// <param name="newConnectionString">Connection string to the proxy server (using the same parameters as <paramref name="connectionString"/>)</param>
        /// <returns>The created and started proxy server</returns>
        public static ProxyServer CreateAndStartProxy(string connectionString, out string newConnectionString)
        {
            // Build builders
            SqlConnectionStringBuilder connStringbuilder = new SqlConnectionStringBuilder(connectionString);
            DataSourceBuilder dataSourceBuilder = new DataSourceBuilder(connStringbuilder.DataSource);

            // Setup proxy
            Task<System.Net.IPHostEntry> ipEntryTask = Dns.GetHostEntryAsync(dataSourceBuilder.ServerName);
            ipEntryTask.Wait();
            System.Net.IPHostEntry serverIpEntry = ipEntryTask.Result;

            ProxyServer proxy = new ProxyServer();
            proxy.RemoteEndpoint = new IPEndPoint(serverIpEntry.AddressList[0], dataSourceBuilder.Port ?? 1433);
            proxy.Start();

            // Switch connection over
            dataSourceBuilder.Protocol = "tcp";
            dataSourceBuilder.ServerName = "127.0.0.1";
            dataSourceBuilder.Port = proxy.LocalPort;
            connStringbuilder.DataSource = dataSourceBuilder.ToString();
            connStringbuilder.Remove("Network Library");

            newConnectionString = connStringbuilder.ToString();
            return proxy;
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:31,代码来源:ProxyServer.cs

示例4: RemoveDatabaseNameFromConnectionString

        internal static string RemoveDatabaseNameFromConnectionString(string connectionString)
        {
            //need to remove the actual database name so that it will not try and login to that individual database, but the whole DB server
            var builder = new SqlConnectionStringBuilder
            {
                ConnectionString = connectionString
            };

            if (connectionString.ToLower().Contains("database"))
            {
                builder.Remove("Database");
            }

            if (connectionString.ToLower().Contains("initial catalog"))
            {
                builder.Remove("initial catalog");
            }

            return builder.ConnectionString;
        }
开发者ID:twistedtwig,项目名称:NHibernateRepository,代码行数:20,代码来源:ConnectionStringHandler.cs

示例5: Save

 private void Save()
 {
     var sqlBuilder = new SqlConnectionStringBuilder(ConnectionString);
     sqlBuilder.DataSource = DataSource;
     sqlBuilder.InitialCatalog = InitialCatalog;
     sqlBuilder.IntegratedSecurity = IsIntegratedSecurity;
     if (!IsIntegratedSecurity)
     {
         sqlBuilder.UserID = UserId;
         sqlBuilder.Password = Password;
     }
     else
     {
         sqlBuilder.Remove("User Id");
         sqlBuilder.Remove("Password");
     }
     ConnectionString = sqlBuilder.ConnectionString;
 }
开发者ID:mdavid626,项目名称:triton,代码行数:18,代码来源:ConnectionStringEditorViewModel.cs

示例6: FixUpConnectionString

        private static string FixUpConnectionString(string connectionString, string providerName)
        {
            DebugCheck.NotEmpty(providerName);

            if (providerName != "System.Data.SqlClient")
            {
                return connectionString;
            }

            var builder = new SqlConnectionStringBuilder(connectionString)
                {
                    MultipleActiveResultSets = true
                };
            builder.Remove("Pooling");

            return builder.ToString();
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:17,代码来源:ReverseEngineerCodeFirstHandler.cs

示例7: EnsureDataBase

		static void EnsureDataBase(string connectionString) {
			var qs = new SqlConnectionStringBuilder(connectionString);
			var dbName = qs.InitialCatalog;
			qs.Remove("Initial Catalog");
			using(var db = new SqlConnection(qs.ConnectionString)) {
				db.Open();
				using(var cmd = new SqlCommand("select db_id(@db)" ,db)) {
					cmd.Parameters.AddWithValue("@db", dbName);
					if(cmd.ExecuteScalar() is DBNull) {
						cmd.CommandText = $"create database [{dbName}]";
						cmd.ExecuteNonQuery();
					}
				}
			}
		}
开发者ID:Rklasens,项目名称:DataBoss,代码行数:15,代码来源:Program.cs

示例8: GetSafeConnectionString

 public static string GetSafeConnectionString(string connectionString){
     var sb = new SqlConnectionStringBuilder(connectionString);
     sb.Remove("Password");
     sb.Remove("User ID");
     return sb.ToString();
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:6,代码来源:DevLogger.cs

示例9: FixUpConnectionString

        private static string FixUpConnectionString(string connectionString, string providerName)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(providerName));

            if (providerName != "System.Data.SqlClient")
            {
                return connectionString;
            }

            var builder = new SqlConnectionStringBuilder(connectionString)
                {
                    MultipleActiveResultSets = true
                };
            builder.Remove("Pooling");

            return builder.ToString();
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:17,代码来源:ReverseEngineerCodeFirstHandler.cs

示例10: ConfigureConnection

        /// <summary>
        /// Removes the Initial Catalog setting from the connection string
        /// </summary>
        /// <param name="connectionString">
        /// The connection string 
        /// </param>
        /// <param name="initialCatalog">
        /// The catalog to connect to 
        /// </param>
        /// <returns>
        /// A connection string without the InitialCatalog 
        /// </returns>
        private static string ConfigureConnection(string connectionString, string initialCatalog = null)
        {
            var builder = new SqlConnectionStringBuilder(connectionString);
            builder.Remove(InitialCatalog);
            if (!string.IsNullOrWhiteSpace(initialCatalog))
            {
                builder.InitialCatalog = initialCatalog;
            }

            builder.Remove("Pooling");
            builder.Pooling = false;
            return builder.ConnectionString;
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:25,代码来源:SqlWorkflowInstanceStoreManager.cs

示例11: InstanceStoreExists

 /// <summary>
 /// Determines if the database exists or not
 /// </summary>
 /// <param name="databaseName">
 /// The database name. 
 /// </param>
 /// <param name="connectionString">
 /// The connection string. 
 /// </param>
 /// <returns>
 /// true if the database exists 
 /// </returns>
 public static bool InstanceStoreExists(string databaseName, string connectionString)
 {
     var builder = new SqlConnectionStringBuilder(connectionString);
     builder.Remove(InitialCatalog);
     using (var conn = new SqlConnection(builder.ConnectionString))
     using (var command = new SqlCommand(DatabaseExistsSql, conn))
     {
         conn.Open();
         command.Parameters.AddWithValue(DatabaseNameParameter, databaseName);
         var result = command.ExecuteScalar();
         return result != null && (int)result == 1;
     }
 }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:25,代码来源:SqlWorkflowInstanceStoreManager.cs


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