请教下各位老师,在Parameters加入了一个参数,但是这个参数的值是可变的字符串数组
请问这样写可以吗,执行不出来数据,但是在后台执行是有数据的,请问哪里错了,麻烦有老师帮我看看吗,谢谢。
public DataTable SelectTaxPayer(params string[] custid)
{
string tmpcust_id = null;
for (int i = 0; i < custid.Length; i++)
{
if (i < custid.Length - 1)
{
tmpcust_id += "'" + custid[i] + "',";
}
else
{
tmpcust_id += "'" + custid[i] + "'";
}
}
OracleConnection conn = new OracleConnection(LoginUtil.ConnStr);
string sqlText = " select * " +
" from table_tmp " +
" where to_char(cust_id) in (:custid) ";
OracleCommand cmd = new OracleCommand(sqlText,conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add(new OracleParameter("custid", OracleType.VarChar, 200));
cmd.Parameters.AddWithValue("custid", tmpcust_id);
//TaxPayerModel taxpayer = null;
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
try
{
conn.Open();
da.Fill(ds);
return ds.Tables[0];
}
catch (Exception ex)
{
return null;
}
finally
{
conn.Close();
}
}