C#使用Oracle.ManagedDataAccess调用Oracle 数据库参数化方法

插入
StringBuilder sskcSql = new StringBuilder();
sskcSql.Append(" insert into PDASSKC(SSKCENT,SSKCSITE,KC001,KC002,KC003,KC004,KC005,KC006,KC007,KC008, "
+ " KC011) “);
sskcSql.Append(” values(:SSKCENT,:SSKCSITE,:KC001,:KC002,:KC003,:KC004,:KC005,:KC006,:KC007,:KC008,"
+ " :KC011)");
sskcSql.Append(strDbKey);
OracleParameter[] parasskc = new OracleParameter[]
{
new OracleParameter(“SSKCENT”, OracleDbType.Int32),
new OracleParameter(“SSKCSITE”, OracleDbType.Varchar2, 10),
new OracleParameter(“KC001”, OracleDbType.Varchar2, 40),
new OracleParameter(“KC002”, OracleDbType.Varchar2, 255),
new OracleParameter(“KC003”, OracleDbType.Varchar2, 255),
new OracleParameter(“KC004”, OracleDbType.Varchar2, 10),
new OracleParameter(“KC005”, OracleDbType.Varchar2, 10),
new OracleParameter(“KC006”, OracleDbType.Varchar2, 30),
new OracleParameter(“KC007”, OracleDbType.Varchar2, 10),
new OracleParameter(“KC008”, OracleDbType.Decimal),
new OracleParameter(“KC011”, OracleDbType.Date)
};
parasskc[0].Value = PDASSKC[i].SSKCENT;//[0]
parasskc[1].Value = PDASSKC[i].SSKCSITE;//[1]
parasskc[2].Value = PDASSKC[i].KC001;//[2]
parasskc[3].Value = PDASSKC[i].KC002;//[3]
parasskc[4].Value = PDASSKC[i].KC003;//[4]
parasskc[5].Value = PDASSKC[i].KC004;//[5]
parasskc[6].Value = PDASSKC[i].KC005;//[6]
parasskc[7].Value = PDASSKC[i].KC006;//[7]
parasskc[8].Value = PDASSKC[i].KC007;//[8]
parasskc[9].Value = PDASSKC[i].KC008;//[9]
parasskc[10].Value = PDASSKC[i].KC011;//[10]
for (int k = 0; k < parasskc.Length; k++)
{
if (parasskc[k].Value == null)
{
parasskc[k].Value = System.DBNull.Value;
}
}

修改
StringBuilder strBQMX = new StringBuilder();
strBQMX.Append(" update PDABQMX set MX007=‘Y’");
strBQMX.Append(" where MX001 like :MX001||’%’ and MX002<=:MX002");
OracleParameter[] paraBQMX = new OracleParameter[]
{
new OracleParameter(“MX001”,OracleDbType.NVarchar2,200),
new OracleParameter(“MX002”,OracleDbType.Varchar2,4)
};
paraBQMX[0].Value = Convert.ToString(bqmx[0].ToString().Trim());
paraBQMX[1].Value = Convert.ToString(bqmx[1].ToString().Trim())

你可能感兴趣的:(C#使用Oracle.ManagedDataAccess调用Oracle 数据库参数化方法)