本文整理汇总了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());
}
示例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());
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}