C#Oracle并非所有变量都已绑定 3C

请问大家:运行程序,错误提示为“并非所有变量都已绑定”,不知道是哪里的错误,请大神帮帮忙,希望能举例说明,否则不知道怎么操作?谢谢!!!补充:从页面选定下拉列表值,传递给控制器,以此条件,对oracle数据库进行查询。

public class C_F_BuyCertController : Controller
{
    public ActionResult Getlist()
    {
        string category = "";
        if (Request.Params["category"] != null) category = Request.Params["category"];
        string chemical = "";
        if (Request.Params["chemical"] != null) chemical = Request.Params["chemical"];
        DataTable dt = new DataTable();
        if(chemical!="")dt = ReList(chemical,category);
        List<C_F_BuyCert> modellist = new List<C_F_BuyCert>();
        int rowscount = dt.Rows.Count;
        if (rowscount > 0)
        {
            C_F_BuyCert buycert;
            for (int n = 0; n < rowscount; n++)
            {
                buycert = new C_F_BuyCert();
                buycert.C_Id = dt.Rows[n]["C_ID"].ToString();
                buycert.Buy_Id = dt.Rows[n]["BUY_ID"].ToString();
                buycert.Spy_Id = dt.Rows[n]["SPY_ID"].ToString();
                buycert.Unit = dt.Rows[n]["UNIT"].ToString();
                buycert.Amount = Convert.ToInt32(dt.Rows[n]["AMOUNT"]);
                buycert.PassAmount = Convert.ToInt32(dt.Rows[n]["PASS_AMOUNT"]);
                buycert.Db_Source = dt.Rows[n]["DB_SOURCE"].ToString();
                modellist.Add(buycert);
            }
        }
        ViewData.Add("list", modellist);
        return View();
    }
    public DataTable ReList(string chemical,string category)
    {
        string ConnectString = "data source=172.16.60.144/orcl;User Id=yzd4hub;Password=yzd4hub;";
        OracleConnection conn = new OracleConnection(ConnectString);//Data Source后面跟数据库的名字,User ID为用户名,Password为密码
        DataTable dt = new DataTable();
        OracleParameter chem = new OracleParameter(":chemical", OracleType.VarChar, 50);
        OracleParameter cat = new OracleParameter(":category", OracleType.VarChar, 50);
            try
            {
                conn.Open();
                string sql = "select a.c_id,a.buy_id,a.spy_id,a.unit,a.amount,a.pass_amount,a.db_source from c_f_buycert a,c_d_chemical b where a.c_id=b.c_id and b.c_name=:chem and b.kind_key=:cat";
                OracleCommand cmd = new OracleCommand(sql, conn);
                cmd.Parameters.Add(chem);
                cmd.Parameters.Add(cat);
                OracleDataAdapter oda = new OracleDataAdapter(cmd);
                oda.Fill(dt);
                return dt;
            }
            finally
            {
                conn.Close();
            }
        }
    }


            <dd>
                <div class="editor-label">
                    化学品种类:
                </div>
                <div class="editor-field">
                    <select id="category" name="category" onchange="getChemical()">
                        <option value=" ">全部化学品 </option>
                        <option value="第一类易制毒化学品">第一类易制毒化学品</option>
                        <option value="第二类易制毒化学品">第二类易制毒化学品</option>
                        <option value="第三类易制毒化学品">第三类易制毒化学品</option>
                    </select>
                    <br />
                </div>
                <div class="editor-label">
                    化学品名称:
                </div>
                <div class="editor-field">
                    <select id="chemical" name="chemical">
                        <option value=" ">化学品名称</option>
                    </select>
                </div>
            </dd>

            <br />
            <dd>
                <input id="Submit1" type="submit" value="查询" onclick="~/Controllers/C_F_BuyCertController/Getlist()" />
                <input id="Reset1" type="reset" value="重置" />
            </dd>
        </dl>
c#

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!