本文整理汇总了C#中System.Data.OleDb.OleDbConnection.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbConnection.GetType方法的具体用法?C# OleDbConnection.GetType怎么用?C# OleDbConnection.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbConnection
的用法示例。
在下文中一共展示了OleDbConnection.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: run
public void run()
{
Exception exp = null;
IDbConnection ICon = new OleDbConnection();
try
{
BeginCase("check IDbConnection is null");
Compare(ICon != null, true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection type");
Compare(ICon.GetType().FullName ,typeof(OleDbConnection).FullName);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
ICon = new OleDbConnection(_ConnectionString);
try
{
BeginCase("check IDbConnection connection string");
Compare(ICon.ConnectionString ,_ConnectionString);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection ConnectionTimeout");
Compare(ICon.ConnectionTimeout ,15);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection state - closed");
Compare(ICon.State ,ConnectionState.Closed);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
ICon.Open();
try
{
BeginCase("check IDbConnection - open");
Compare(ICon.State ,ConnectionState.Open );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check IDbConnection CreateCommand");
IDbCommand cmd = ICon.CreateCommand();
Compare(cmd.GetType().FullName ,typeof(OleDbCommand).FullName);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (ICon.State == ConnectionState.Open) ICon.Close();
}
示例2: openConnection
/// <summary>
///
/// </summary>
/// <param name="connectionName">Name of connection (should be held in sources connections collection) to be opened
/// and placed in openConnections if not already there. (If it is already there then nothing is done)</param>
/// <returns></returns>
private void openConnection(RRConnectionString connection)
{
if (openConnections.ContainsKey(connection.Name))
// Have already opened that connection, do nothing
return;
else
{
var connString = buildConnectionString(connection.Name);
try
{
/*
// Have not yet opened that connection, so open it and save to collection
if (connection.DatabaseType == DatabaseType.Teradata)
{
var openConnection = new TdConnection(connString);
openConnection.Open();
openConnections.Add(connection.Name, openConnection);
}
else
{
*/
var openConnection = new OleDbConnection(connString);
openConnection.Open();
var connType = openConnection.GetType();
openConnections.Add(connection.Name, openConnection);
}
catch (Exception ex)
{
throw new ApplicationException(string.Format("Error trying to open connection with {0}: {1}.", connString, getFullErrorMessage(ex)));
}
}
}