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


C# IDbConnection类代码示例

本文整理汇总了C#中IDbConnection的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection类的具体用法?C# IDbConnection怎么用?C# IDbConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IDbConnection类属于命名空间,在下文中一共展示了IDbConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _addRptParams

 private static void _addRptParams(IDbConnection conn, String rptUID, Params prms, String userUID, String remoteIP) {
   var v_prms = new Params();
   v_prms.SetValue("p_rpt_uid", rptUID);
   var v_sql = "begin xlr.clear_rparams(:p_rpt_uid); end;";
   SQLCmd.ExecuteScript(conn, v_sql, v_prms, 120);
   v_sql = "begin xlr.add_rparam(:p_rpt_uid, :p_prm_name, :p_prm_type, :p_prm_val, :p_usr_uid, :p_remote_ip); end;";
   foreach (var v_prm in prms) {
     v_prms.SetValue("p_prm_name", v_prm.Name);
     String v_prmValue;
     var v_prmTypeStr = "A";
     if (v_prm.Value != null) {
       var v_prmType = v_prm.ParamType ?? v_prm.Value.GetType();
       if (Utl.TypeIsNumeric(v_prmType)) {
         v_prmTypeStr = "N";
         v_prmValue = "" + v_prm.Value;
         v_prmValue = v_prmValue.Replace(",", ".");
       } else if (v_prmType == typeof(DateTime)) {
         v_prmTypeStr = "D";
         v_prmValue = ((DateTime)v_prm.Value).ToString("yyyy.MM.dd HH:mm:ss");
       } else
         v_prmValue = "" + v_prm.Value;
     } else
       continue;
     v_prms.SetValue("p_prm_type", v_prmTypeStr);
     v_prms.SetValue("p_prm_val", v_prmValue);
     v_prms.SetValue("p_usr_uid", userUID);
     v_prms.SetValue("p_remote_ip", remoteIP);
     SQLCmd.ExecuteScript(conn, v_sql, v_prms, 120);
   }
 }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:30,代码来源:CQueueDefaultImpl.cs

示例2: LoadData

		public override void LoadData(DataRow CurrentDataRow, IDbConnection conn)
		{
			IsLoaded = false;
			CurrentFRDBase = (GISADataset.FRDBaseRow)CurrentDataRow;
			
			IsLoaded = true;
		}
开发者ID:aureliopires,项目名称:gisa,代码行数:7,代码来源:PanelSeleccaoUnidadesFisicas.cs

示例3: AffectData

        public static int AffectData(string TSQL, IDbConnection myConn, IDbTransaction myTrans, List<IDbDataParameter> myParams)
        {
            bool mustClose = false;
            if (myConn == null)
            {
                mustClose = true;
                myConn = clsConn.getConnOLE();
            }
            if (myConn.State != ConnectionState.Open)
                myConn.Open();
            OleDbCommand myCMD = new OleDbCommand();
            //
            myCMD.Connection = myConn as OleDbConnection;
            if (myTrans != null)
                myCMD.Transaction = myTrans as OleDbTransaction;
            //
            myCMD.CommandType = CommandType.Text;
            myCMD.CommandText = TSQL;
            myCMD.CommandTimeout = 180000;//3 phut
            //
            if (myParams != null)
                AttachParameters(myCMD, myParams);

            int CMDResult = myCMD.ExecuteNonQuery();
            //
            if (mustClose) myConn.Close();
            return CMDResult;
        }
开发者ID:huamanhtuyen,项目名称:TagLo1,代码行数:28,代码来源:clsDalOLE.cs

示例4: Save

        public static ResponsePackage Save(RequestObjectPackage<EventTypeModel> request, IDbConnection connectionID, IDbTransaction transactionID)
        {
            EventTypeModel obj = request.requestData;
            string sql = string.Empty;

            if (obj.ID > 0)
            {
                sql = string.Format(
                    " update EVENT_TYPES set NAME = {0} " + Environment.NewLine +
                    " where ID = {1} returning ID",
                    SQL.FromString(obj.name),
                    SQL.FromNumber(obj.ID)
                );
            }
            else
            {
                sql = string.Format(
                    " insert into EVENT_TYPES (NAME) " + Environment.NewLine +
                    " values ({0}) returning ID",
                    SQL.FromString(obj.name)
                );
            }
            ResponseTablePackage res = DBUtils.ExecuteSQL(sql, connectionID, true, transactionID);
            res.ThrowExceptionIfError();
            return new ResponsePackage() { resultID = res.resultID };
        }
开发者ID:GOPbIHbI4,项目名称:FormGenerator,代码行数:26,代码来源:EventTypesRepository.cs

示例5: Add

 public void Add(IDbConnection connection)
 {
     lock (connections) {
     connections[connection.ConnectionString] =
       new WeakReference(connection);
       }
 }
开发者ID:nmaier,项目名称:simpleDLNA,代码行数:7,代码来源:FileStoreVacuumer.cs

示例6: BanManager

        /// <summary>
        /// Initializes a new instance of the <see cref="TShockAPI.DB.BanManager"/> class.
        /// </summary>
        /// <param name="db">A valid connection to the TShock database</param>
		public BanManager(IDbConnection db)
		{
			database = db;

			var table = new SqlTable("Bans",
			                         new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
			                         new SqlColumn("Name", MySqlDbType.Text),
									 new SqlColumn("UUID", MySqlDbType.Text),
			                         new SqlColumn("Reason", MySqlDbType.Text),
                                     new SqlColumn("BanningUser", MySqlDbType.Text),
                                     new SqlColumn("Date", MySqlDbType.Text),
                                     new SqlColumn("Expiration", MySqlDbType.Text)
				);
			var creator = new SqlTableCreator(db,
			                                  db.GetSqlType() == SqlType.Sqlite
			                                  	? (IQueryBuilder) new SqliteQueryCreator()
			                                  	: new MysqlQueryCreator());
			try
			{
				creator.EnsureTableStructure(table);
			}
			catch (DllNotFoundException)
			{
				System.Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
				throw new Exception("Could not find a database library (probably Sqlite3.dll)");
			}
		}
开发者ID:sliekasirdis79,项目名称:TShock,代码行数:31,代码来源:BanManager.cs

示例7: ReadColumns

        protected override IList<IDataTableColumn> ReadColumns(IDbConnection connectionString, string databaseName)
        {
            const string sql = @"
select 'Foo' ""TableSchema""
        , rf.RDB$RELATION_NAME ""TableName""
        , rf.RDB$FIELD_NAME ""ColumnName""
        , case when rf.RDB$NULL_FLAG is null then 1 else 0 end ""Nullable""
        , t.RDB$TYPE_NAME ""Type""
        , case when f.RDB$COMPUTED_SOURCE is null then 0 else 1 end ""Generated""
        , case when exists(select *
            from RDB$RELATION_CONSTRAINTS rc
                inner join RDB$INDEX_SEGMENTS xs on xs.RDB$INDEX_NAME = rc.RDB$INDEX_NAME
            where rc.RDB$RELATION_NAME = rf.RDB$RELATION_NAME and xs.RDB$FIELD_NAME = rf.RDB$FIELD_NAME
                and rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY') then 1 else 0 end ""PrimaryKey""
        , f.RDB$FIELD_LENGTH ""Length""
        , f.RDB$FIELD_PRECISION ""Precision""
        , f.RDB$FIELD_SCALE ""Scale""
        , rf.RDB$DEFAULT_VALUE ""DefaultValue""
    from RDB$RELATION_FIELDS rf
        inner join RDB$FIELDS f on f.RDB$FIELD_NAME = rf.RDB$FIELD_SOURCE
        inner join RDB$TYPES t on t.RDB$TYPE = f.RDB$FIELD_TYPE and t.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
    where rf.RDB$SYSTEM_FLAG = 0
    order by rf.RDB$RELATION_NAME, rf.RDB$FIELD_POSITION
";

            return DataCommand.Find<IDataTableColumn>(connectionString, sql, "@db", databaseName, ReadColumn);
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:27,代码来源:FirebirdSchemaLoader.Columns.cs

示例8: GetColumnList

        public List<MColumn> GetColumnList(IDbConnection conn, string tableName)
        {
            string sql = string.Format(@"SELECT NAME,TBNAME,TBCREATOR,REMARKS,COLTYPE,LENGTH, NULLS,DEFAULT,KEYSEQ
            FROM sysibm.syscolumns where tbname ='{0}'", tableName);

            DB2Command cmd = new DB2Command(sql, (DB2Connection)conn);
            List<MColumn> ret = new List<MColumn>();

            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    MColumn model = new MColumn();
                    model.ColumnName = DBUtil.GetDBValueStr(reader, "NAME");
                    model.Creator = DBUtil.GetDBValueStr(reader, "TBCREATOR");
                    model.Remarks = DBUtil.GetDBValueStr(reader, "REMARKS");
                    model.ColType = DBUtil.GetDBValueStr(reader, "COLTYPE");
                    model.Length = DBUtil.GetDBValueInt(reader, "LENGTH");
                    model.IsNullable = DBUtil.GetDBValueBool(reader, "NULLS");
                    model.DefaultValue = DBUtil.GetDBValueStr(reader, "DEFAULT");
                    model.KeySeq = DBUtil.GetDBValueInt(reader, "KEYSEQ");

                    ret.Add(model);
                }
            }

            return ret;
        }
开发者ID:HelloAmy,项目名称:01component,代码行数:28,代码来源:DGetSchema.cs

示例9: List

 public static List<MeetingRoomCheckin> List(IDbConnection db, string email, long day)
 {
     using (IDbCommand command = db.CreateCommand())
      {
          command.CommandText = "select id, day, timestamp, _user, _meetingroom, _booking form checkin where _user = @Email and day = @Day order by timestamp";
          List<MeetingRoomCheckin> MRC = new List<MeetingRoomCheckin>();
          IDbDataParameter p = command.CreateParameter();
          p.ParameterName = "@Email";
          p.Value = email;
          command.Parameters.Add(p);
          IDbDataParameter p2 = command.CreateParameter();
          p2 = command.CreateParameter();
          p2.ParameterName = "@Day";
          p2.Value = day;
          command.Parameters.Add(p2);
          using (IDataReader reader = command.ExecuteReader())
          {
              while (reader.Read())
              {
                  MRC.Add(new MeetingRoomCheckin(reader));
              }
              return MRC;
          }
      }
 }
开发者ID:rogerthat-platform,项目名称:rogerthat-api-dotnet,代码行数:25,代码来源:MeetingRoomCheckin.cs

示例10: Login

        public Result<customer_account> Login(IDbConnection db, string userName, string pwd, IPAddress ip)
        {
            string userNameLC = userName.ToLower();

            var loginInfo = db.Query<customer_login_password>("SELECT * FROM customer_login_password WHERE lower(username)[email protected] OR lower(email)[email protected] ", new { userName = userNameLC }).FirstOrDefault();

            if (loginInfo == null || string.Compare(loginInfo.unhashed_password, pwd, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return Result<customer_account>.Null(ErrorCodes.InvalidUserNameOrPassword);
            }

            var user = GetCustomerById(db, loginInfo.customer_account_id);
            int id = user.Data.id;

            // Change country code only IF the database has not store this value before //
            if (string.IsNullOrEmpty(user.Data.country_code) || string.IsNullOrEmpty(user.Data.country_name))
            {
                ip.GetCountryCode(c => user.Data.country_code = c, n => user.Data.country_name = n);
            }
          

            // TODO: Update
            user.Data.last_login_at = DateTime.UtcNow;
            db.Execute("UPDATE customer_account SET [email protected]_login_at, [email protected]_code, [email protected]_name", user.Data);

            return user;
        }
开发者ID:vietplayfuri,项目名称:Asp_Master,代码行数:27,代码来源:Login-Query.cs

示例11: CheckDeleteControl

 /// <summary>
 /// Проверить возможность удаления компонента
 /// </summary>
 /// <param name="request">бъект-оболочка RequestPackage, содержащая в поле requestID ID компонента</param>
 /// <param name="connectionID">Объект подключения к базе данных</param>
 /// <returns>Объект-оболочка ResponsePackagе</returns>
 public ResponsePackage CheckDeleteControl(RequestPackage request, IDbConnection connectionID, IDbTransaction transactionID)
 {
     string sql = string.Format(
         " select id from CONTROL_QUERY_MAPPING where control_id = {0} " +
         "  union " +
         " select id from FORM_IN_PARAMETERS where control_id = {0} " +
         "  union " +
         " select id from FORM_OUT_PARAMETERS where control_id = {0} " +
         "  union " +
         " select id from ACTION_PARAMETERS where control_id = {0} " +
         "  union " +
         " select id from QUERY_QUERY_IN_PARAMETER where control_id = {0} ",
         request.requestID
     );
     ResponseTablePackage res = DBUtils.OpenSQL(sql, connectionID, transactionID);
     res.ThrowExceptionIfError();
     if (res.resultData.Rows.Count > 0)
     {
         return new ResponsePackage() { resultCode = -1, resultMessage = "Удаление компонента невозможно. Проверьте все ссылки на него." };
     }
     else
     {
         return new ResponsePackage() { resultCode = 0, resultMessage = "Удаление возможно." };
     }
 }
开发者ID:GOPbIHbI4,项目名称:FormGenerator,代码行数:31,代码来源:ControlsRepository.cs

示例12: Create

 internal IDbCommand Create(IDbConnection connection, CommandBuilder commandBuilder)
 {
     var command = connection.CreateCommand();
     command.CommandText = commandBuilder.Text;
     PrepareCommand(commandBuilder, command);
     return command;
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:7,代码来源:CommandHelper.cs

示例13: GetTableList

        public List<MTableDesc> GetTableList(IDbConnection conn, string creater)
        {
            string strSql = @"select NAME, CREATOR,CTIME,REMARKS from sysibm.systables where type='T' ";

            if (!string.IsNullOrEmpty(creater))
            {
                strSql += string.Format("and creator='{0}'", creater);
            }

            DB2Command cmd = new DB2Command(strSql, (DB2Connection)conn);

            List<MTableDesc> ret = new List<MTableDesc>();
            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    MTableDesc model = new MTableDesc();
                    model.TableName = reader["NAME"] == DBNull.Value ? string.Empty : reader["NAME"].ToString();
                    model.Creator = reader["CREATOR"] == DBNull.Value ? string.Empty : reader["CREATOR"].ToString();
                    model.CreateDateTime = reader["CTIME"] == DBNull.Value ? DateTime.Parse("1990-01-01") : Convert.ToDateTime(reader["CTIME"].ToString());
                    model.Remarks = reader["REMARKS"] == DBNull.Value ? string.Empty : reader["REMARKS"].ToString();

                    ret.Add(model);
                }
            }

            return ret;
        }
开发者ID:HelloAmy,项目名称:01component,代码行数:28,代码来源:DGetSchema.cs

示例14: TryPrepareValue

        protected override bool TryPrepareValue(IDbConnection connection, ColumnMapper columnMapper, TableInfo table, string columnName, ref object value)
        {
            //we insert tenant as suspended so it can't be accessed before restore operation is finished
            if (table.Name.Equals("tenants_tenants", StringComparison.InvariantCultureIgnoreCase) && 
                columnName.Equals("status", StringComparison.InvariantCultureIgnoreCase))
            {
                value = (int)TenantStatus.Restoring;
                return true;
            }

            if (table.Name.Equals("tenants_quotarow", StringComparison.InvariantCultureIgnoreCase) &&
                columnName.Equals("last_modified", StringComparison.InvariantCultureIgnoreCase))
            {
                value = DateTime.UtcNow;
                return true;
            }

            if ((table.Name == "core_user" || table.Name == "core_group") && columnName == "last_modified")
            {
                value = DateTime.UtcNow.AddMinutes(2);
                return true;
            }

            return base.TryPrepareValue(connection, columnMapper, table, columnName, ref value);
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:25,代码来源:TenantsModuleSpecifics.cs

示例15: RuntimeContext

 public RuntimeContext(IDbConnection connection, IDbTransaction transaction, IDbCommandExecutor executor, IProviderMetadata providerMetadata, IMigrationStepMetadata stepMetadata)
     : base(providerMetadata, stepMetadata)
 {
     _connection = connection;
     _transaction = transaction;
     _executor = executor;
 }
开发者ID:dradovic,项目名称:MigSharp,代码行数:7,代码来源:RuntimeContext.cs


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