同一组数据,用参数化查询,返回错误0,拼接字符串,返回正确值1。不知何故?
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
public
bool
IsMeetRzlx2(
string
rzlx,
string
item,
string
wlbm,
string
gysh)
{
string sql = @" SELECT COUNT(0) FROM ssaln.ttcibd924400 b
WHERE b.t$suno=:v_gysh
AND b.t$item=:v_item
AND b.t$rzlx=:v_rzlx
AND b.t$mitm=:v_mitm " ;
OracleParameter[] _param = {
new OracleParameter( " v_gysh " , gysh),
new OracleParameter( " v_item " , wlbm),
new OracleParameter( " v_rzlx " , rzlx),
new OracleParameter( " v_mitm " , item)
};
OracleConnection conn = new OracleConnection( " … " );
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.Parameters.AddRange(_param);
conn.Open();
object obj = cmd.ExecuteScalar();
conn.Close();
return (obj != DBNull.Value && Convert.ToInt32(obj) > 0 ) ? true : false ;
}
{
string sql = @" SELECT COUNT(0) FROM ssaln.ttcibd924400 b
WHERE b.t$suno=:v_gysh
AND b.t$item=:v_item
AND b.t$rzlx=:v_rzlx
AND b.t$mitm=:v_mitm " ;
OracleParameter[] _param = {
new OracleParameter( " v_gysh " , gysh),
new OracleParameter( " v_item " , wlbm),
new OracleParameter( " v_rzlx " , rzlx),
new OracleParameter( " v_mitm " , item)
};
OracleConnection conn = new OracleConnection( " … " );
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.Parameters.AddRange(_param);
conn.Open();
object obj = cmd.ExecuteScalar();
conn.Close();
return (obj != DBNull.Value && Convert.ToInt32(obj) > 0 ) ? true : false ;
}
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
public
bool
IsMeetRzlx2(
string
rzlx,
string
item,
string
wlbm,
string
gysh)
{
string sql = " SELECT COUNT(0) FROM ssaln.ttcibd924400 b "
+ " WHERE b.t$suno=' " + gysh + " ' "
+ " AND b.t$item=' " + wlbm + " ' "
+ " AND b.t$rzlx=' " + rzlx + " ' "
+ " AND b.t$mitm=' " + item + " ' " ;
OracleConnection conn = new OracleConnection( " … " );
OracleCommand cmd = new OracleCommand(sql, conn);
conn.Open();
object obj = cmd.ExecuteScalar();
conn.Close();
return (obj != DBNull.Value && Convert.ToInt32(obj) > 0 ) ? true : false ;
}
{
string sql = " SELECT COUNT(0) FROM ssaln.ttcibd924400 b "
+ " WHERE b.t$suno=' " + gysh + " ' "
+ " AND b.t$item=' " + wlbm + " ' "
+ " AND b.t$rzlx=' " + rzlx + " ' "
+ " AND b.t$mitm=' " + item + " ' " ;
OracleConnection conn = new OracleConnection( " … " );
OracleCommand cmd = new OracleCommand(sql, conn);
conn.Open();
object obj = cmd.ExecuteScalar();
conn.Close();
return (obj != DBNull.Value && Convert.ToInt32(obj) > 0 ) ? true : false ;
}