出于某种原因,每当我尝试执行页面时,下面的代码都会返回 ORA-01036:非法变量名称/编号。我尝试删除它读取 cmd.BindByName = true 的部分,它返回另一个错误,该错误并非所有变量绑定。下面是我的代码:
try
{
int row;
DataSet dataset = new DataSet();
OracleCommand cmd = new OracleCommand(sql, conn);
for (row = 0; row < gvParameters.Rows.Count; row++)
{
TextBox text = (TextBox)gvParameters.Rows[row]
.FindControl("txtParamValue");
cmd.Parameters.Add(gvParameters.Rows[row].Cells[1].Text, text.Text);
}
cmd.BindByName = true;
OracleDataAdapter adapter = new OracleDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(dataset);
if (conn.State == ConnectionState.Open)
{
conn.Close();
conn.Dispose();
}
gvResults.DataSource = dataset.Tables[0];
gvResults.DataBind();
}
catch (Exception ex)
{
X.MessageBox.Alert("Information", ex.ToString()).Show();
conn.Close();
conn.Dispose();
}
这是我正在使用的查询。
SELECT
*
FROM
(
SELECT
ROW_NUMBER() OVER (ORDER BY NULL) AS No
, cspOutput.*
FROM
(
SELECT DISTINCT *
FROM
(
SELECT DISTINCT
wl.specname
,wep.paramnamename dataname
,wep.paramvalue || ' - ' || NVL(ht.name, ' ') datavalue
,wep.paramsequence
,e.employeename
,e.fullname
--,'WIP' AS Type
,we.equipmentname
,we.trackinemployeename
,c.containername
FROM container c
JOIN a_wiplot wl ON wl.containerid = c.containerid
JOIN a_wiplotdetails wld ON wl.wiplotid = wld.wiplotid
JOIN a_wiplotdetailswafers wldw ON wld.wiplotdetailsid = wldw.wiplotdetailsid
JOIN a_wipequipment we ON we.containerid = wl.containerid
JOIN a_wipequipmentparams wep ON we.wipequipmentid= wep.wipequipmentid
LEFT JOIN otherdb.hw_inventory ht ON wep.paramvalue = ht.BARCODE
LEFT JOIN employee e ON we.trackinemployeename = e.employeename
WHERE c.containername = ?lotID AND wep.paramvalue IS NOT NULL
UNION ALL
SELECT DISTINCT
hml.specname
,wep.paramnamename dataname
,wep.paramvalue || ' - ' || NVL(ht.name, ' ') datavalue
,wep.paramsequence
,e.employeename
,e.fullname
--,'TrackInOut' AS Type
,we.equipmentname
,we.trackinemployeename
,c.containername
FROM container C
JOIN a_wipequipmenthistory we ON c.containerid = we.containerid OR c.splitfromid = we.containerid
JOIN historymainline HML on hml.historysummaryid = we.wipequipmentlinkid AND (hml.historyid = c.containerid OR hml.historyid = c.splitfromid)
JOIN a_wipequipmentparamshistory wep ON wep.wipequipmenthistoryid = we.wipequipmenthistoryid
LEFT JOIN otherdb.hw_inventory ht ON wep.paramvalue = ht.BARCODE
LEFT JOIN employee e ON we.trackinemployeename = e.employeename
WHERE c.containername = ?lotID AND wep.paramvalue IS NOT NULL
)
)cspOutput
)
WHERE No BETWEEN (((?BLOCKOF200ROWS - 1) * 200) + 1) AND (?BLOCKOF200ROWS * 200)
感谢您的帮助。