本文整理汇总了C#中System.Data.Common.DbConnectionStringBuilder.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# DbConnectionStringBuilder.Clear方法的具体用法?C# DbConnectionStringBuilder.Clear怎么用?C# DbConnectionStringBuilder.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Common.DbConnectionStringBuilder
的用法示例。
在下文中一共展示了DbConnectionStringBuilder.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetConnectionInformationsFrom
/// <summary>
/// This function returns login and password of user for a passed NpgsqlConnection
/// </summary>
/// <param name="connection">the current opened DbConnection</param>
/// <param name="login">returned login corresponding to the NpgsqlConnection passed</param>
/// <param name="password">returned password corresponding to the NpgsqlConnection passed</param>
/// <returns>true if succeed, false otherwise (connection null or not opened)</returns>
public static bool GetConnectionInformationsFrom(
IDbConnection connection,
out string login,
out string password)
{
login = string.Empty;
password = string.Empty;
if ((connection != null) && (connection.State == System.Data.ConnectionState.Open))
{
DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
builder.ConnectionString = connection.ConnectionString;
if (builder != null)
{
object value = null;
bool result = builder.TryGetValue("User Id", out value);
if (result)
{
login = value.ToString();
}
result &= builder.TryGetValue("Password", out value);
if (result)
{
password = value.ToString();
}
builder.Clear();
return result;
}
}
return false;
}
示例2: Connect
//private void Delete()
//{
// Process proc = new Process();
// proc.StartInfo.CreateNoWindow = true;
// proc.StartInfo.FileName = "cmd.exe";
// proc.StartInfo.UseShellExecute = false;
// proc.StartInfo.RedirectStandardError = true;
// proc.StartInfo.RedirectStandardInput = true;
// proc.StartInfo.RedirectStandardOutput = true;
// proc.Start();
// proc.StandardInput.WriteLine("del " + m_strFilePathName.Substring(0, m_strFilePathName.Length - 3) + "ldb");
// proc.StandardInput.WriteLine("del " + m_strFilePathName);
// //proc.StandardInput.WriteLine("delete " + m_strPath + ".tmp.mdb");
// proc.Close();
//}
private bool Connect(string strFilePathName)
{
try
{
m_strFilePathName = strFilePathName;
if (File.Exists(strFilePathName))
{
try
{
File.Delete(strFilePathName);
}
catch (Exception ee)
{
//Delete();
strFilePathName += "_1.mdb";
}
}
try
{
ADOX.Catalog catalog = new ADOX.Catalog();
catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePathName + ";Jet OLEDB:Engine Type=5");
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(catalog.ActiveConnection);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(catalog);
}
catch (Exception ee)
{
}
DbConnectionStringBuilder dcsBuilder = new DbConnectionStringBuilder();
dcsBuilder.Clear();
dcsBuilder.Add("Provider", "Microsoft.Jet.Oledb.4.0");
dcsBuilder.Add("User ID", "Admin");
dcsBuilder.Add("Password", "");
dcsBuilder.Add("Data Source", @strFilePathName);
m_pOleDbConnection = new OleDbConnection(dcsBuilder.ConnectionString);
m_pOleDbConnection.Open();
//m_pPolygonNodeTable = new PolygonNodeTable(m_pOleDbConnection, true);
//m_pLineNodeExTable = new LineNodeExTable(m_pOleDbConnection, true);
//m_pLineNodeTable = new LineNodeTable(m_pOleDbConnection, true);
return true;
}
catch (Exception ex)
{
Logger.WriteErrorLog(ex);
}
return false;
}