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


C# Database.CreateConnection方法代码示例

本文整理汇总了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();
 }
开发者ID:fmanoellima,项目名称:Report-Generator-Service,代码行数:7,代码来源:SqlDataAccess.cs

示例2: BeginTransaction

 public DbTransaction BeginTransaction()
 {
     _db = DatabaseFactory.CreateDatabase();
     _connection = _db.CreateConnection();
     _connection.Open();
     _transaction = _connection.BeginTransaction();
     return _transaction;
 }
开发者ID:shhyder,项目名称:MapApplication,代码行数:8,代码来源:Base.cs

示例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;
 }
开发者ID:joeiren,项目名称:quant.AidSystem,代码行数:16,代码来源:DBFactory.cs

示例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
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:19,代码来源:TRNCommon.cs

示例6: DAReportPurchase

 public DAReportPurchase()
 {
     DatabaseProviderFactory factory = new DatabaseProviderFactory();
     odb = factory.Create("PS");
     ocn = odb.CreateConnection();
 }
开发者ID:isvelarder,项目名称:sispeperweb,代码行数:6,代码来源:DAReportPurchase.cs

示例7: DAGenerics

 public DAGenerics()
 {
     odb = DatabaseFactory.CreateDatabase("PS");
     ocn = odb.CreateConnection();
 }
开发者ID:isvelarder,项目名称:sispeper,代码行数:5,代码来源:DAGenerics.cs

示例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();
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:9,代码来源:DatabaseExtensions.CreateConnection.cs

示例9: DASales

 public DASales()
 {
     DatabaseProviderFactory factory = new DatabaseProviderFactory();
     odb = factory.Create("PS");
     ocn = odb.CreateConnection();
 }
开发者ID:isvelarder,项目名称:sispeperweb,代码行数:6,代码来源:DASales.cs

示例10: DataTransaction

        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="db">数据库</param>
        public DataTransaction(Database db)
        {
            _db = db;

            IDbConnection dbConn = db.CreateConnection();
            SetConnectionMode(dbConn);
            dbConn.Dispose();
        }
开发者ID:SaintLoong,项目名称:PD,代码行数:12,代码来源:DataTransaction.cs

示例11: SetConnection

 public void SetConnection()
 {
     _db = DatabaseFactory.CreateDatabase();
     _connection = _db.CreateConnection();
 }
开发者ID:shhyder,项目名称:MapApplication,代码行数:5,代码来源:Base.cs

示例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;
        }
开发者ID:uwitec,项目名称:O2O,代码行数:35,代码来源:DbHelper.cs

示例13: DAManagement

 public DAManagement()
 {
     odb = DatabaseFactory.CreateDatabase("PS");
     ocn = odb.CreateConnection();
 }
开发者ID:isvelarder,项目名称:sispeper,代码行数:5,代码来源:DAManagement.cs

示例14: DAOutputGoods

 public DAOutputGoods()
 {
     odb = DatabaseFactory.CreateDatabase("PS");
     ocn = odb.CreateConnection();
 }
开发者ID:isvelarder,项目名称:sispeper,代码行数:5,代码来源:DAOutputGoods.cs

示例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;
        }
开发者ID:paraneye,项目名称:WebService,代码行数:24,代码来源:DALHelper.cs


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