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


C# ConnectionString.ToString方法代码示例

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


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

示例1: CanSetUserIdAndPasswordInConnectionStringThatAlreadyHasOne

 public void CanSetUserIdAndPasswordInConnectionStringThatAlreadyHasOne()
 {
     string initialConnectionString = String.Format("server=localhost; database=JoeRandom; user id={0}; password={1}; ;", "Kill", "Bill");
     ConnectionString newConnectionString = new ConnectionString(initialConnectionString, userIdTokens, passwordTokens);
     newConnectionString.UserName = userName;
     newConnectionString.Password = password;
     string actualConnectionString = String.Format("server=localhost; database=JoeRandom; user id={0}; password={1}; ;", userName, password);
     Assert.AreEqual(actualConnectionString, newConnectionString.ToString());
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:9,代码来源:ConnectionStringFixture.cs

示例2: CanAddCredentialsToConnectionStringThatDoesNotHaveThem

 public void CanAddCredentialsToConnectionStringThatDoesNotHaveThem()
 {
     string initialConnectionString = @"server=(local)\SQLEXPRESS; database=RandomData; ; ;";
     connectionString = new ConnectionString(initialConnectionString, userIdTokens, passwordTokens);
     connectionString.UserName = userName;
     connectionString.Password = password;
     string actualConnectionString = String.Format(@"server=(local)\SQLEXPRESS; database=RandomData; ; ;user id={0};password={1};",
                                                   userName, password);
     Assert.AreEqual(actualConnectionString, connectionString.ToString());
 }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:10,代码来源:ConnectionStringFixture.cs

示例3: Initialize

		public void Initialize()
		{
			var connectionString = new ConnectionString("..\\..\\Database.sdf");
			var config = Fluently.Configure()
				.Database(MsSqlCeConfiguration.Standard.ConnectionString(connectionString.ToString()))
				.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Person>())
				.ExposeConfiguration(x => x.SetProperty("connection.release_mode", "on_close"))
				.BuildConfiguration();

			connectionString.CreateDatabase(config);

			var sessions = config.BuildSessionFactory();
			Session = sessions.OpenSession();
		}
开发者ID:halllo,项目名称:QueryOver.it,代码行数:14,代码来源:Tests.cs

示例4: CheckNoPasswordWithPersistInfoEqualsFalseForDynamicConnectionString

 public void CheckNoPasswordWithPersistInfoEqualsFalseForDynamicConnectionString()
 {
     try
     {
         CreateUser();
         ConnectionString testString =
             new ConnectionString(@"server=(local)\SQLEXPRESS;database=Northwind;uid=entlib;pwd=hdf7&834k(*KA;Persist Security Info=false", "UserId,UId", "Password,Pwd");
         SqlDatabase sqlDatabase = new SqlDatabase(testString.ToString());
         DbConnection dbConnection = sqlDatabase.CreateConnection();
         dbConnection.Open();
         dbConnection.Close();
         string connectionString = dbConnection.ConnectionString;
         if (connectionString.ToLower().Contains("pwd") || connectionString.ToLower().Contains("password"))
         {
             Assert.Fail();
         }
     }
     finally
     {
         DeleteUser();
     }
 }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:22,代码来源:SqlDatabaseFixture.cs

示例5: UpdateConnectionConfiguration

 public void UpdateConnectionConfiguration(string oldName, string newName, ConnectionString connectionString, bool requiresAuthentication)
 {
     var toEdit = Configuration.ConnectionStrings.FirstOrDefault(x => x.Name.Equals(oldName));
     if (toEdit != null)
     {
         toEdit.Name = newName;
         toEdit.ConnectionString = connectionString.ToString();
         toEdit.RequiresAuthentication = requiresAuthentication;
     }
     else
     {
         Configuration.ConnectionStrings.Add(new NamedConnectionString
             {
                 Name = newName,
                 ConnectionString = connectionString.ToString(),
                 RequiresAuthentication = requiresAuthentication
             });
     }
     Configuration.Save();
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:20,代码来源:MainViewModel.cs

示例6: AddConnectionConfiguration

 public void AddConnectionConfiguration(string name, ConnectionString connectionString,
                                        bool requiresAuthentication)
 {
     Configuration.ConnectionStrings.Add(new NamedConnectionString
     {
         Name = name,
         ConnectionString = connectionString.ToString(),
         RequiresAuthentication = requiresAuthentication
     });
     Configuration.Save();
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:11,代码来源:MainViewModel.cs


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