简体   繁体   中英

ORA-01036: illegal variable name/number while adding paramater to an oracle command

For some reason, my code below returns ORA-01036: illegal variable name/number whenever I try to execute the page. I have tried removing the part where it reads cmd.BindByName = true and it returns another error which is not all variable bound. Below is my code:

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();
}

Here is the query that I am using.

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)

Thanks for helping guys.

My bad. Turns out that I am passing the incorrect data. Sorry for bringing this up. I got confused when I put all my variables on my watchlist. Instead of keying in 0, I inputted 1. Now it is working. Thanks :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM