本文整理汇总了C#中OracleCommand.CreateParameter方法的典型用法代码示例。如果您正苦于以下问题:C# OracleCommand.CreateParameter方法的具体用法?C# OracleCommand.CreateParameter怎么用?C# OracleCommand.CreateParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OracleCommand
的用法示例。
在下文中一共展示了OracleCommand.CreateParameter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddParameter
private void AddParameter(OracleCommand dbCmd, string paramName, object paramValue, ParameterDirection direction)
{
if (dbCmd == null)
return;
OracleParameter param = dbCmd.CreateParameter();
param.Direction = direction;
param.ParameterName = paramName;
if (paramValue == null)
{
param.Value = DBNull.Value;
}
else
{
Type valueType = paramValue.GetType();
if (valueType.IsEnum)
param.Value = (int)paramValue;
else if (valueType == typeof(Boolean))
param.Value = (bool)paramValue ? 1 : 0;
else if (valueType == typeof(DateTime) && DateTime.MinValue.Equals(paramValue))
param.Value = DBNull.Value;
else if (valueType == typeof(Guid))
param.Value = ((Guid)paramValue).ToByteArray();
else
param.Value = paramValue;
}
dbCmd.Parameters.Add(param);
}
示例2: Prepare
public virtual void Prepare(OracleCommand command)
{
OracleParameter param = command.CreateParameter();
param.ParameterName = this.m_parameterName;
if (!this.m_inferType)
{
param.DbType = this.m_dbType;
}
if (this.m_precision != 0)
{
param.Precision = this.m_precision;
}
if (this.m_scale != 0)
{
param.Scale = this.m_scale;
}
if (this.m_size != 0)
{
param.Size = this.m_size;
}
command.Parameters.Add(param);
}
示例3: SetParameters
private static void SetParameters(Procedure procedure, OracleCommand cmd, IDictionary<string, object> suppliedParameters)
{
int i = 0;
foreach (var parameter in procedure.Parameters)
{
if (parameter.IsReturnOrOutput())
{
var p = cmd.CreateParameter();
p.ConfigureOutputParameterFromArgument(parameter);
cmd.Parameters.Add(p);
}
else
{
object value;
suppliedParameters.TryGetValue("_" + i, out value);
cmd.Parameters.Add(parameter.Name, value);
i++;
}
}
}
示例4: Refresh
public bool Refresh(TableManager.Table table)
{
OracleCommand cmd = new OracleCommand(ALL_CONSTRAINTS_TABLE_SELECT, conn);
cmd.BindByName = true;
// set up parameters
// schemaParam
OracleParameter schemaParam = cmd.CreateParameter();
schemaParam.ParameterName = "owner";
schemaParam.OracleDbType = OracleDbType.Char;
schemaParam.Direction = System.Data.ParameterDirection.Input;
schemaParam.Value = table.Owner;
cmd.Parameters.Add(schemaParam);
// tableParam
OracleParameter tableParam = cmd.CreateParameter();
tableParam.ParameterName = "table_name";
tableParam.OracleDbType = OracleDbType.Char;
tableParam.Direction = System.Data.ParameterDirection.Input;
tableParam.Value = table.Name;
cmd.Parameters.Add(tableParam);
// execute
OracleDataReader odr = cmd.ExecuteReader();
if (!odr.HasRows)
return false;
// purge old data
purgeConstraintData(table);
while (odr.Read())
{
ConstraintBase constraint = LoadConstraint(odr);
constraints.Add(constraint);
}
return true;
}
示例5: RefreshColumns
public bool RefreshColumns(TableManager.Table table)
{
// set up command and parameters
OracleCommand cmd = new OracleCommand(ALL_TAB_COLUMNS_TABLE_SELECT, conn);
OracleParameter ownerParam = cmd.CreateParameter();
ownerParam.ParameterName = "owner";
ownerParam.OracleDbType = OracleDbType.Char;
ownerParam.Direction = System.Data.ParameterDirection.Input;
ownerParam.Value = table.Name;
cmd.Parameters.Add(ownerParam);
OracleParameter tableParam = cmd.CreateParameter();
tableParam.ParameterName = "table_name";
tableParam.OracleDbType = OracleDbType.Char;
tableParam.Direction = System.Data.ParameterDirection.Input;
tableParam.Value = table.Owner;
cmd.Parameters.Add(tableParam);
// prepare data reader
OracleDataReader odr = cmd.ExecuteReader();
if (!odr.HasRows)
return false;
// purge table columns data
purgeTableColumnsData(table);
while (odr.Read())
{
TableColumn column = LoadColumn(odr);
columns.Add(column);
}
return true;
}