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


C# OleDb.OleDbParameter类代码示例

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


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

示例1: ExecuteInsert

 //执行单条插入语句,并返回id,不需要返回id的用ExceuteNonQuery执行。
 public int ExecuteInsert(string sql, OleDbParameter[] parameters)
 {
   //Debug.WriteLine(sql);
   var connection = pool.New();
   try
   {
     OleDbCommand cmd = new OleDbCommand(sql, connection);
     try
     {
       connection.Open();
       if (parameters != null)
         cmd.Parameters.AddRange(parameters);
       cmd.ExecuteNonQuery();
       cmd.CommandText = @"select @@identity";
       int value = Int32.Parse(cmd.ExecuteScalar().ToString());
       return value;
     }
     catch (Exception e)
     {
       throw e;
     }
   }
   finally
   {
     pool.Delete(connection);
   }
 }
开发者ID:shengqh,项目名称:RCPA.Core,代码行数:28,代码来源:Access.cs

示例2: GetInsuranceFundByID

        public InsuranceFund GetInsuranceFundByID(int InsuranceFundID)
        {
            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                string sqlText = string.Format(@"select
                    InsuranceFundID,
                    PeopleID,
                    InsuranceFundType,
                    Number,
                    PaymentAddress,
                    PaymentStartDate,
                    PaymentEndDate,
                    BasicNum
                    from {0} where [email protected]", _InsuranceFundTableName);
                var paras = new OleDbParameter[1];
                paras[0] = new OleDbParameter("InsuranceFundID", InsuranceFundID);

                var reader = new OLESqlHelper().GetReader(sqlText, connection, paras);
                if (reader.Read()) {
                    int i = 0;
                    var InsuranceFund = new InsuranceFund();
                    InsuranceFund.InsuranceFundID = reader.GetInt32(i++);
                    InsuranceFund.PeopleID = reader.GetInt32(i++);
                    InsuranceFund.InsuranceFundType = (int)reader.GetInt32(i++);
                    InsuranceFund.Number = reader.GetString(i++);
                    InsuranceFund.PaymentAddress = reader.GetString(i++);
                    InsuranceFund.PaymentStartDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++);
                    InsuranceFund.PaymentEndDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++);
                    InsuranceFund.BasicNum = reader.GetFloat(i++);

                    return InsuranceFund;
                } else {
                    return null;
                }
            }
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:35,代码来源:InsuranceFundDAL.cs

示例3: CreateDateTimeOleDbParameter

 private OleDbParameter CreateDateTimeOleDbParameter(string parameterName, DateTime dt)
 {
     OleDbParameter p = new OleDbParameter(parameterName, OleDbType.DBTimeStamp);
     p.Direction = ParameterDirection.Input;
     p.Value = AccessConnectionHelper.RoundToSeconds(dt);
     return p;
 }
开发者ID:ericjohnolson,项目名称:NadaNtd,代码行数:7,代码来源:AccessPersonalizationProvider.cs

示例4: GetTicket

        public Ticket GetTicket(int ticketId)
        {
            Ticket ticket = null;
            String sql = "SELECT Id, AccountId, Comment, DateOpened, State FROM tblTickets WHERE [email protected]";

            using (OleDbConnection conn = this.GetConnection())
            {
                conn.Open();

                OleDbCommand sqlCmd = new OleDbCommand(sql, conn);
                OleDbParameter idParam = new OleDbParameter("@Id", ticketId);
                sqlCmd.Parameters.Add(idParam);

                using (OleDbDataReader reader = sqlCmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        reader.Read();
                        ticket.TicketNumber = ticketId;
                        ticket.AccountId = reader.GetInt32(reader.GetOrdinal("AccountId"));
                        ticket.Comment = reader.GetString(reader.GetOrdinal("Comment"));
                        ticket.DateOpened = reader.GetDateTime(reader.GetOrdinal("DateOpened"));
                        ticket.State = (TicketState)reader.GetByte(reader.GetOrdinal("State"));
                    }
                    reader.Close();
                }
                conn.Close();
             return ticket;
            }
        }
开发者ID:AdriVanHoudt,项目名称:School,代码行数:30,代码来源:OleDbManager.cs

示例5: Delete

        public static bool Delete(string file, string client)
        {
            bool result = true;
            OleDbConnection connect = null;
            try
            {
                connect = openConnect();
                string strCommand = "DELETE FROM Infor WHERE FileName = @file AND FromClient = @client";
                OleDbCommand command = new OleDbCommand(strCommand, connect);
                OleDbParameter parameter ;

                parameter = new OleDbParameter("@file", OleDbType.VarChar);
                parameter.Value = file;
                command.Parameters.Add(parameter);

                parameter = new OleDbParameter("@client", OleDbType.VarChar);
                parameter.Value = client;
                command.Parameters.Add(parameter);

                command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = false;
            }
            finally
            {
                if (connect == null && connect.State == System.Data.ConnectionState.Open)
                    connect.Close();
            }
            return result;
        }
开发者ID:HungHuynh,项目名称:HHFileShare,代码行数:32,代码来源:DAOInfor.cs

示例6: GetRewardRecordByID

        public RewardRecord GetRewardRecordByID(int recordID)
        {
            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                string sqlText = string.Format(@"select
                    RecordID,
                    PeopleID,
                    RewardDate,
                    RewardContent
                    from {0} where [email protected]", _RewardRecordTableName);
                var paras = new OleDbParameter[1];
                paras[0] = new OleDbParameter("RecordID", recordID);

                var reader = new OLESqlHelper().GetReader(sqlText, connection, paras);
                if (reader.Read()) {
                    int i = 0;
                    var RewardRecord = new RewardRecord();
                    RewardRecord.RecordID = reader.GetInt32(i++);
                    RewardRecord.PeopleID = reader.GetInt32(i++);
                    RewardRecord.RewardDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++);
                    RewardRecord.RewardContent = reader.GetString(i++);
                    return RewardRecord;
                } else {
                    return null;
                }
            }
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:26,代码来源:RewardRecordDAL.cs

示例7: genParameter

        protected DbParameter genParameter(String paramName, OleDbType type, int size, Object value)
        {
            if (value == null)
                value = DBNull.Value;

            DbParameter param = null;

            if (type == OleDbType.DBTimeStamp)
            {
                if (value == DBNull.Value)
                {
                    param = new OleDbParameter(paramName, value);
                }
                else
                {
                    param = new OleDbParameter(paramName, ((Nullable<DateTime>)value).Value);
                }
            }
            else
            {
                param = new OleDbParameter(paramName, type, size);
                param.Value = value;
            }

            return param;
        }
开发者ID:zyh329,项目名称:fpv2,代码行数:26,代码来源:BaseDAO.cs

示例8: GetGamesInRange

    public override List<CGamesDetails> GetGamesInRange(decimal Min, decimal Max, int CategoryID)
    {
        using (OleDbConnection conn = new OleDbConnection(
            ConfigurationManager.ConnectionStrings["gameData_AccessConnection"].ConnectionString))
        {
            conn.Open();
            string cmdText = "SELECT GameID,GameTitle,GamePictureURL,GamePrice,CategoryID,GameReleaseDate FROM	tblGame WHERE	(GamePrice >= @min) AND (GamePrice <= @max) AND ([email protected])";
            OleDbCommand cmd = new OleDbCommand(cmdText, conn);

            OleDbParameter[] OleParam = new OleDbParameter[]
            {
                new OleDbParameter("min",OleDbType.Decimal),
                new OleDbParameter("max", OleDbType.Decimal),
                new OleDbParameter("category", OleDbType.Integer)
            };

            OleParam[0].Value = Min;
            OleParam[1].Value = Max;
            OleParam[2].Value = CategoryID;

            cmd.Parameters.AddRange(OleParam);

            IDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            if (reader.Read())
                return GetGameDetailsCollectionFromReader(reader);
            else
                return null;
        }
    }
开发者ID:rowyhoffy,项目名称:MyFirstRepo,代码行数:30,代码来源:GamesDBAccessProvider.cs

示例9: ExecuteCommand

 /// <summary>
 /// 执行OleDbCommand(增删改)
 /// </summary>
 /// <param name="sql">sql语句</param>
 /// <param name="value">sql语句单个参数(对应表中字段)</param>
 /// <returns>受影响行数</returns>
 public static int ExecuteCommand(string sql, OleDbParameter value)
 {
     OleDbCommand cmd = new OleDbCommand(sql, GetDbConnection);
     cmd.Parameters.Add(value);
     int result = cmd.ExecuteNonQuery();
     return result;
 }
开发者ID:Paulyoufu,项目名称:elijah_window,代码行数:13,代码来源:DBHelper.cs

示例10: GetPeopleFamilyByID

        public PeopleFamily GetPeopleFamilyByID(int familyPeopleID)
        {
            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                string sqlText = string.Format(@"select
                    PeopleFamilyID,
                    PeopleID,
                    Relation,
                    FamilyPeopleName,
                    WorkUnit,
                    Title,
                    PhoneNum,
                    Address
                    from {0} where [email protected]", _peopleFamilyTableName);
                var paras = new OleDbParameter[1];
                paras[0] = new OleDbParameter("PeopleFamilyID", familyPeopleID);

                var reader = new OLESqlHelper().GetReader(sqlText, connection, paras);
                if (reader.Read()) {
                    int i = 0;
                    var peopleFamily = new PeopleFamily();
                    peopleFamily.PeopleFamilyID = reader.GetInt32(i++);
                    peopleFamily.PeopleID = reader.GetInt32(i++);
                    peopleFamily.Relation = reader.GetString(i++);
                    peopleFamily.FamilyPeopleName = reader.GetString(i++);
                    peopleFamily.WorkUnit = reader.GetString(i++);
                    peopleFamily.Title = reader.GetString(i++);
                    peopleFamily.PhoneNum = reader.GetString(i++);
                    peopleFamily.Address = reader.GetString(i++);

                    return peopleFamily;
                } else {
                    return null;
                }
            }
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:35,代码来源:PeopleFamilyDAL.cs

示例11: GetPeopleFamilyList

        public List<PeopleFamily> GetPeopleFamilyList(int peopleID)
        {
            string sqlText = string.Format(@"select
                FamilyPeopleID,
                Relation,
                FamilyPeopleName,
                WorkUnit,
                Title,
                PhoneNum,
                Address
                from {0}
                where [email protected]"
                , _peopleFamilyTableName);

            var paras = new OleDbParameter[1];
            paras[0] = new OleDbParameter("PeopleID", peopleID);

            var table = new OLESqlHelper().GetTable(sqlText, paras);

            var peopleFamilyList = new List<PeopleFamily>();
            foreach (DataRow row in table.Rows) {
                var peopleFamily = new PeopleFamily() {
                    PeopleFamilyID = (int)row["FamilyPeopleID"],
                    Relation = row["Relation"].ToString(),
                    FamilyPeopleName = row["FamilyPeopleName"].ToString(),
                    WorkUnit = row["WorkUnit"].ToString(),
                    Title = row["Title"].ToString(),
                    PhoneNum = row["PhoneNum"].ToString(),
                    Address = row["Address"].ToString()
                };
                peopleFamilyList.Add(peopleFamily);
            }
            return peopleFamilyList;
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:34,代码来源:PeopleFamilyDAL.cs

示例12: GetPeoplePicList

        public List<PeoplePic> GetPeoplePicList(int peopleID)
        {
            string sqlText = string.Format(@"select
                PicID,
                PicTitle,
                PicPath
                from {0}
                where [email protected]"
                , _PeoplePicTableName);

            var paras = new OleDbParameter[1];
            paras[0] = new OleDbParameter("PeopleID", peopleID);

            var table = new OLESqlHelper().GetTable(sqlText, paras);

            var PeoplePicList = new List<PeoplePic>();
            foreach (DataRow row in table.Rows) {
                var PeoplePic = new PeoplePic() {
                    PicID = (int)row["PicID"],
                    PicTitle = row["PicTitle"].ToString(),
                    PicPath = row["PicPath"].ToString(),
                };
                PeoplePicList.Add(PeoplePic);
            }
            return PeoplePicList;
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:26,代码来源:PeoplePicDAL.cs

示例13: GetPeoplePicByID

        public PeoplePic GetPeoplePicByID(int PicID)
        {
            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                string sqlText = string.Format(@"select
                    PicID,
                    PeopleID,
                    PicTitle,
                    PicPath
                    from {0} where [email protected]", _PeoplePicTableName);
                var paras = new OleDbParameter[1];
                paras[0] = new OleDbParameter("PicID", PicID);

                var reader = new OLESqlHelper().GetReader(sqlText, connection, paras);
                if (reader.Read()) {
                    int i = 0;
                    var PeoplePic = new PeoplePic();
                    PeoplePic.PicID = reader.GetInt32(i++);
                    PeoplePic.PeopleID = reader.GetInt32(i++);
                    PeoplePic.PicTitle = reader.GetString(i++);
                    PeoplePic.PicPath = reader.GetString(i++);
                    return PeoplePic;
                } else {
                    return null;
                }
            }
        }
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:26,代码来源:PeoplePicDAL.cs

示例14: ExecuteNonQuery

 //执行带参数的sql语句,返回影响的记录数(insert,update,delete)
 public int ExecuteNonQuery(string sql, OleDbParameter[] parameters)
 {
   //Debug.WriteLine(sql);
   //Debug.WriteLine(sql);
   var connection = pool.New();
   try
   {
     OleDbCommand cmd = new OleDbCommand(sql, connection);
     try
     {
       connection.Open();
       if (parameters != null)
         cmd.Parameters.AddRange(parameters);
       int rows = cmd.ExecuteNonQuery();
       return rows;
     }
     catch (Exception e)
     {
       throw e;
     }
   }
   finally
   {
     pool.Delete(connection);
   }
 }
开发者ID:shengqh,项目名称:RCPA.Core,代码行数:27,代码来源:Access.cs

示例15: getDocumentTypes

 public List<DocumentType> getDocumentTypes()
 {
     var parameters = new OleDbParameter[] {};
     return
         CreateList<DocumentType>(
             BuildSqlSelect(DocumentType._TABLE_NAME, new String[] { ALL }, new String[] { }), parameters);
 }
开发者ID:UtrsSoftware,项目名称:ATMLWorkBench,代码行数:7,代码来源:LookupTablesDAO.cs


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