本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Database.CreateConnection方法的具体用法?C# Database.CreateConnection怎么用?C# Database.CreateConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Data.Database
的用法示例。
在下文中一共展示了Database.CreateConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginTransaction
public void BeginTransaction()
{
_db = new SqlDatabase(_strConnection);
_dbConn = _db.CreateConnection();
_dbConn.Open();
_dbTrans = _dbConn.BeginTransaction();
}
示例2: BeginTransaction
public DbTransaction BeginTransaction()
{
_db = DatabaseFactory.CreateDatabase();
_connection = _db.CreateConnection();
_connection.Open();
_transaction = _connection.BeginTransaction();
return _transaction;
}
示例3: GetSchema
/// <summary>
/// 获取指定表名的架构信息
/// </summary>
/// <param name="db"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public static DataTable GetSchema(Database db, string tableName)
{
DbDataAdapter ap = db.GetDataAdapter();
DbCommand cmd = db.GetSqlStringCommand(string.Format("SELECT * FROM {0}", tableName));
cmd.Connection = db.CreateConnection();
ap.SelectCommand = cmd;
DataTable t = new DataTable();
ap.FillSchema(t, SchemaType.Mapped);
return t;
}
示例4: TestInitialize
public void TestInitialize()
{
EnvironmentHelper.AssertOracleClientIsInstalled();
DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
db = factory.Create("OracleTest");
storedProcedure = db.GetStoredProcCommand("NWND_CustOrdersOrders");
connection = db.CreateConnection();
connection.Open();
storedProcedure.Connection = connection;
cache = new ParameterCache();
baseFixture = new ParameterDiscoveryFixture(storedProcedure);
}
开发者ID:VAllens,项目名称:EntLibContrib.Data.Oracle.ManagedDataAccess,代码行数:13,代码来源:OracleParameterDiscoveryFixture.cs
示例5: OpenAndGetConnection
public DbConnection OpenAndGetConnection(string ConfigConnectionDB)
{
#region
try
{
USEDB = DatabaseFactory.CreateDatabase(ConfigConnectionDB);
ConnectionDB = ConfigConnectionDB;
Conn = USEDB.CreateConnection();
Conn.Open();
return Conn;
}
catch (Exception ex)
{
throw ex;
}
#endregion
}
示例6: DAReportPurchase
public DAReportPurchase()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory();
odb = factory.Create("PS");
ocn = odb.CreateConnection();
}
示例7: DAGenerics
public DAGenerics()
{
odb = DatabaseFactory.CreateDatabase("PS");
ocn = odb.CreateConnection();
}
示例8: CreateConnection
/// <summary>
/// 创建并返回与当前 <see cref="DbProviderFactory"/> 关联的 <see cref="DbConnection"/> 对象。
/// </summary>
/// <param name="database">表示当前 <see cref="Microsoft.Practices.EnterpriseLibrary.Data.Database"/> 对象。</param>
/// <returns>与当前 <see cref="DbProviderFactory"/> 关联的 <see cref="DbConnection"/> 对象。</returns>
public static DbConnection CreateConnection(Database database)
{
return database.CreateConnection();
}
示例9: DASales
public DASales()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory();
odb = factory.Create("PS");
ocn = odb.CreateConnection();
}
示例10: DataTransaction
/// <summary>
/// 构造
/// </summary>
/// <param name="db">数据库</param>
public DataTransaction(Database db)
{
_db = db;
IDbConnection dbConn = db.CreateConnection();
SetConnectionMode(dbConn);
dbConn.Dispose();
}
示例11: SetConnection
public void SetConnection()
{
_db = DatabaseFactory.CreateDatabase();
_connection = _db.CreateConnection();
}
示例12: GetSingleBySqlTrans
/// <summary>
/// 执行SQL语句事务,返回查询结果(object)。
/// </summary>
/// <param name="dc">查询语句</param>
/// <param name="db">操作目标数据库</param>
/// <returns>查询结果(object)</returns>
public static object GetSingleBySqlTrans(DbCommand dc, Database db)
{
object obj;
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
using (DbTransaction transaction = connection.BeginTransaction())
{
try
{
PrepareCommand(ref dc, db);
obj = db.ExecuteScalar(dc);
transaction.Commit();
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
obj = null;
}
}
catch (System.Exception e)
{
transaction.Rollback();
throw new Exception(e.Message);
}
connection.Close();
}
}
return obj;
}
示例13: DAManagement
public DAManagement()
{
odb = DatabaseFactory.CreateDatabase("PS");
ocn = odb.CreateConnection();
}
示例14: DAOutputGoods
public DAOutputGoods()
{
odb = DatabaseFactory.CreateDatabase("PS");
ocn = odb.CreateConnection();
}
示例15: UpdateDataTable
public static DataSet UpdateDataTable(
Database db,
DataSet ds,
string tablename,
string insert_sp_name, string[] insert_columns,
string update_sp_name, string[] update_columns,
string delete_sp_name, string[] delete_columns,
RowStatus rowstate)
{
SqlDataAdapter da = new SqlDataAdapter();
da.InsertCommand = SqlHelper.CreateCommand((SqlConnection)db.CreateConnection(), insert_sp_name, insert_columns);
da.UpdateCommand = SqlHelper.CreateCommand((SqlConnection)db.CreateConnection(), update_sp_name, update_columns);
da.DeleteCommand = SqlHelper.CreateCommand((SqlConnection)db.CreateConnection(), delete_sp_name, delete_columns);
if (rowstate == RowStatus.None)
da.Update(ds.Tables[tablename]);
else
if (ds.Tables[tablename].Select("", "", (DataViewRowState)Convert.ToInt32(rowstate)).Length > 0)
{
da.Update(ds.Tables[tablename].Select("", "", (DataViewRowState)Convert.ToInt32(rowstate)));
}
return ds;
}