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


C# OleDbCommand.CreateParameter方法代码示例

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


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

示例1: AddInParameter

 /// <summary>
 /// 增加参数列表
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="parameterName">参数名</param>
 /// <param name="dbType">参数类型</param>
 /// <param name="value">参数值</param>
 public void AddInParameter(OleDbCommand cmd, string parameterName, DbType dbType, object value)
 {
     OleDbParameter dbParameter = cmd.CreateParameter();
     dbParameter.DbType = dbType;
     dbParameter.ParameterName = parameterName;
     dbParameter.Value = value;
     dbParameter.Direction = ParameterDirection.Input;
     cmd.Parameters.Add(dbParameter);
 }
开发者ID:pjjwpc,项目名称:SCZYDJGJK,代码行数:16,代码来源:AccessHelper.cs

示例2: Test_Command_CreateParameter

        private static void Test_Command_CreateParameter()
        {
            using (OleDbCommand cmd = new OleDbCommand("select * from code where s_name=?;", conn))
            {
                OleDbParameter para = cmd.CreateParameter();
                para.Value = 'X';
                para.ParameterName = "s_name";
                cmd.Parameters.Add(para);

                OleDbDataReader reader = cmd.ExecuteReader();
                reader.Read();
                Assert.AreEqual(reader.GetString(1), "Mixed");
            }
        }
开发者ID:CUBRID,项目名称:cubrid-oledb,代码行数:14,代码来源:TestOleDbCommand.cs

示例3: Test_Command_Prepare

        private static void Test_Command_Prepare()
        {
            (new OleDbCommand("drop table if exists t", conn)).ExecuteNonQuery();
            (new OleDbCommand("create table t(id int)", conn)).ExecuteNonQuery();

            using (OleDbCommand cmd = new OleDbCommand("insert into t(id) value(?);", conn))
            {
                OleDbParameter para = cmd.CreateParameter();
                para.Value = 10;
                para.OleDbType = OleDbType.Integer;
                para.ParameterName = "id";
                cmd.Parameters.Add(para);

                cmd.Prepare();
                cmd.ExecuteNonQuery();

                int count = GetTableRowsCount("t",conn);
                Assert.AreEqual(count, 1);
            }
        }
开发者ID:CUBRID,项目名称:cubrid-oledb,代码行数:20,代码来源:TestOleDbCommand.cs

示例4: InitCmdUpdate

 private void InitCmdUpdate()
 {
     CmdUpdate = new OleDbCommand();
     CmdUpdate.CommandText =
         "UPDATE Company SET  CompanyName= @CompanyName" +
         " WHERE ID = @ID";
     CmdUpdate.Connection = DBConnect.DBConnection;
     OleDbParameter prm = new OleDbParameter();
     prm.ParameterName = "CompanyName";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "ID";
     prm.OleDbType = OleDbType.Integer;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
 }
开发者ID:IlyaKrotkih,项目名称:DocumentsControll,代码行数:18,代码来源:Company.cs

示例5: InitCmdInsert

 private void InitCmdInsert()
 {
     CmdInsert = new OleDbCommand();
     CmdInsert.CommandText =
         "INSERT INTO Company (CompanyName,ID)" +
         " VALUES (@CompanyName,@ID)";
     CmdInsert.Connection = DBConnect.DBConnection;
     OleDbParameter prm = new OleDbParameter();
     prm.ParameterName = "CompanyName";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "ID";
     prm.OleDbType = OleDbType.Integer;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
 }
开发者ID:IlyaKrotkih,项目名称:DocumentsControll,代码行数:18,代码来源:Company.cs

示例6: SetObject

				/// <summary>
				/// Sets the value of a parameter using an object.  The given argument object will be converted to the
				/// corresponding SQL type before being sent to the database.
				/// </summary>
				/// <param name="command">Command object to be changed.</param>
				/// <param name="parameterIndex">One-based index of the parameter to be set.</param>
				/// <param name="parameter">The object containing the input parameter value.</param>
				public void SetObject(OleDbCommand command, int parameterIndex, Object parameter)
				{
					if (command.Parameters.Count < parameterIndex)
						command.Parameters.Add(command.CreateParameter());
					command.Parameters[parameterIndex - 1].Value = parameter;
				}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:13,代码来源:SupportClass.cs

示例7: SetNull

				/// <summary>
				/// Sets a parameter to SQL NULL.
				/// </summary>
				/// <param name="command">Command object to be changed.</param>
				/// <param name="parameterIndex">One-based index of the parameter to be set.</param>
				/// <param name="targetSqlType">The SQL type to be sent to the database.</param>
				public void SetNull(OleDbCommand command, int parameterIndex, int sqlType)
				{
					if (command.Parameters.Count < parameterIndex)
						command.Parameters.Add(command.CreateParameter());
					command.Parameters[parameterIndex - 1].Value = Convert.DBNull;
					command.Parameters[parameterIndex - 1].OleDbType = (OleDbType) sqlType;
				}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:13,代码来源:SupportClass.cs

示例8: AssignParamsToCommand

 private static void AssignParamsToCommand(OleDbCommand command, object[] args)
 {
     foreach (object arg in args)
     {
         OleDbParameter param = command.CreateParameter();
         param.Value = arg == null ? DBNull.Value : arg;
         command.Parameters.Add(param);
     }
 }
开发者ID:project-first,项目名称:latino,代码行数:9,代码来源:DatabaseConnection.cs

示例9: AddOutParameter

 /// <summary>
 /// 增加输出参数 适用于存储过程
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="parameterName">参数名</param>
 /// <param name="dbType">参数类型</param>
 /// <param name="size">参数大小</param>
 public void AddOutParameter(OleDbCommand cmd, string parameterName, DbType dbType, int size)
 {
     OleDbParameter dbParameter = cmd.CreateParameter();
     dbParameter.DbType = dbType;
     dbParameter.ParameterName = parameterName;
     dbParameter.Size = size;
     dbParameter.Direction = ParameterDirection.Output;
     cmd.Parameters.Add(dbParameter);
 }
开发者ID:pjjwpc,项目名称:SCZYDJGJK,代码行数:16,代码来源:AccessHelper.cs

示例10: AddReturnParameter

 /// <summary>
 /// 增加返回参数 适用于存储过程
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="parameterName">参数名</param>
 /// <param name="dbType">参数类型</param>
 public void AddReturnParameter(OleDbCommand cmd, string parameterName, DbType dbType)
 {
     OleDbParameter dbParameter = cmd.CreateParameter();
     dbParameter.DbType = dbType;
     dbParameter.ParameterName = parameterName;
     dbParameter.Direction = ParameterDirection.ReturnValue;
     cmd.Parameters.Add(dbParameter);
 }
开发者ID:pjjwpc,项目名称:SCZYDJGJK,代码行数:14,代码来源:AccessHelper.cs

示例11: InitCmdUpdate

 private void InitCmdUpdate()
 {
     CmdUpdate = new OleDbCommand();
     CmdUpdate.CommandText =
         "UPDATE ClientPassport SET PassSery = @PassSery, PassNum = @PassNum, Registred = @Registred, IssuedDate = @IssuedDate, IssuedCode =  @IssuedCode, IssuedBy = @IssuedBy, DateOfBirth = @DateOfBirth " +
         "WHERE(((ClientPassport.[ID]) = @ID)); ";
     CmdUpdate.Connection = DBConnect.DBConnection;
     OleDbParameter prm = new OleDbParameter();
     prm.ParameterName = "PassSery";
     prm.OleDbType = OleDbType.Char;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "PassNum";
     prm.OleDbType = OleDbType.Char;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "Registred";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "IssuedDate";
     prm.OleDbType = OleDbType.DBDate;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "IssuedCode";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "IssuedBy";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "DateOfBirth";
     prm.OleDbType = OleDbType.DBDate;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
     prm = CmdUpdate.CreateParameter();
     prm.ParameterName = "ID";
     prm.OleDbType = OleDbType.Integer;
     prm.Direction = ParameterDirection.Input;
     CmdUpdate.Parameters.Add(prm);
 }
开发者ID:IlyaKrotkih,项目名称:DocumentsControll,代码行数:48,代码来源:Passport.cs

示例12: InitCmdInsert

 private void InitCmdInsert()
 {
     CmdInsert = new OleDbCommand();
     CmdInsert.CommandText =
         "INSERT INTO ClientPassport (PassSery,PassNum,Registred,ID,IssuedDate,IssuedCode,IssuedBy,DateOfBirth)" +
         "VALUES (@PassSery,@PassNum,@Registred,@ID,@IssuedDate,@IssuedCode,@IssuedBy,@DateOfBirth)";
     CmdInsert.Connection = DBConnect.DBConnection;
     OleDbParameter prm = new OleDbParameter();
     prm.ParameterName = "PassSery";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "PassNum";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "Registred";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "ID";
     prm.OleDbType = OleDbType.Integer;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "IssuedDate";
     prm.OleDbType = OleDbType.DBDate;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "IssuedCode";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "IssuedBy";
     prm.OleDbType = OleDbType.VarChar;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
     prm = CmdInsert.CreateParameter();
     prm.ParameterName = "DateOfBirth";
     prm.OleDbType = OleDbType.DBDate;
     prm.Direction = ParameterDirection.Input;
     CmdInsert.Parameters.Add(prm);
 }
开发者ID:IlyaKrotkih,项目名称:DocumentsControll,代码行数:48,代码来源:Passport.cs


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