0
我想將值傳遞給參數TYPE 1`。但我不知道如何做到這一點。請幫助獲取未選中複選框列表的項目
string constr = ConfigurationManager.ConnectionStrings["OracleConn"].ConnectionString;
string strQuery = "SELECT * FROM xxcus.xxacl_pn_expense_info";
int count = 1;
List<OracleParameter> parameters = new List<OracleParameter>();
List<string> conditions = new List<string>();
foreach (ListItem li in ddlStatus.Items)
{
if (li.Selected)
{
conditions.Add(string.Format(":TYPE{0}", count));
//OracleParameter p = new OracleParameter(string.Format(":TYPE{0}"), OracleType.VarChar);
OracleParameter p = new OracleParameter(string.Format(":TYPE{0}", count), OracleType.NVarChar);
p.Value = li.Value;
parameters.Add(p);
count++;
}
}
string whereCondition = string.Empty;
if (conditions.Count > 0)
{
whereCondition = " Where type IN (" + string.Join(",", conditions) + ")";
}
using (OracleConnection conn = new OracleConnection(constr))
{
using (OracleCommand cmd = new OracleCommand(strQuery + whereCondition))
{
cmd.Parameters.AddRange(parameters.ToArray());
cmd.Parameters.Add(":TYPE", OracleType.VarChar) = what to pass here?
using (OracleDataAdapter oda = new OracleDataAdapter(cmd))
{
cmd.Connection = conn;
using (DataTable dtcheck = new DataTable())
{
oda.Fill(dtcheck);
GridExpInfo.DataSource = dtcheck;
GridExpInfo.DataBind();
}
}
}
}
你當前的代碼有什麼問題? –