I am writing an web app to load data from DB2 ISeries. I wrote this query and put in a string:
queryStr = "DECLARE @TEMP CHAR(50)";
queryStr += " CASE WHEN (address1='' AND Adress2='') THEN SET @TEMP ='(Adress1||Adress2||Adress3) AS Address,' ";
queryStr += " WHEN (address1='' AND Adress2 <>'') THEN SET @TEMP ='(Adress2||Adress2||'<br />'||Adress3) AS Address,' ";
queryStr += " WHEN (address1<>'' AND Adress2 ='') THEN SET @TEMP ='(Adress2||'<br />'||Adress2||Adress3) AS Address,' ";
queryStr += " WHEN (address1<>'' AND Adress2 <>'') THEN SET @TEMP ='(Adress2||'<br />'||Adress2||'<br />'||Adress3) AS Address,' ";
queryStr += " END ";
queryStr = "select ID AS StudendID,key AS studentKey, @TEMP ,";
queryStr += "CUCYST AS City,CUSTE AS State,ZIPCD9 AS Zipcode ";
queryStr += "from studendTable WHERE ID like '%" + StuNoTxt.Text.Trim().ToUpper() + "%'";
queryStr += " CASE WHEN (address1='' AND Adress2='') THEN SET @TEMP ='(Adress1||Adress2||Adress3) AS Address,' ";
queryStr += " WHEN (address1='' AND Adress2 <>'') THEN SET @TEMP ='(Adress2||Adress2||'<br />'||Adress3) AS Address,' ";
queryStr += " WHEN (address1<>'' AND Adress2 ='') THEN SET @TEMP ='(Adress2||'<br />'||Adress2||Adress3) AS Address,' ";
queryStr += " WHEN (address1<>'' AND Adress2 <>'') THEN SET @TEMP ='(Adress2||'<br />'||Adress2||'<br />'||Adress3) AS Address,' ";
queryStr += " END ";
queryStr = "select ID AS StudendID,key AS studentKey, @TEMP ,";
queryStr += "CUCYST AS City,CUSTE AS State,ZIPCD9 AS Zipcode ";
queryStr += "from studendTable WHERE ID like '%" + StuNoTxt.Text.Trim().ToUpper() + "%'";
when I run the query, I got error
Error! SQL0418 Use of parameter marker not valid.
How can I make this query work?????
Please help. Thanks
Dee