I have done a bunch of Select statements with AddWithValue's and Add's but this one I can't seem to get to work. This works fine when I put the number in instead of the @orderNum. Tried with @orderNum and '@orderNum' when I put the '' nothing happens on button click but when I use @orderNum it says it can't find ORDERNUM in the table. The value in the SQL table is a CHAR FOR BIT DATA so maybe that has something to do with it? Ideas?
End of my select statement:
WHERE POITEM.ORDNO = @orderNum
Add :
cmd.Parameters.Add(new OleDbParameter("@orderNum", poTextBox.Text));
The entire SELECT statement (the resulting big C# string concatenated from smaller chunks):
SELECT
CAST(POITEM.ITNBR as char(15) ccsid 37) as itemno,
CAST(POITEM.ITDSC as char(15) ccsid 37) as ITDSC,
CAST(POITEM.HOUSE as char(15) ccsid 37) as hou,
CAST(POITEM.REFNO as char(15) ccsid 37) as REF,
CAST(POITEM.STAIC as char(15) ccsid 37) as staic,
POITEM.QTYOR,
CAST(POITEM.UNMSR as char(15) ccsid 37) as unmsr,
POITEM.UMCNV,
POITEM.DKQTY,
POITEM.STKQT,
CAST(POITEM.JOBNO as char(15) ccsid 37) as job,
CAST(POITEM.DPTNO as char(15) ccsid 37) as dept,
CAST(POITEM.VCLNB as char(15) ccsid 37) as vclnb,
CAST(POITEM.WHSLC as char(15) ccsid 37) as whsloc,
POITEM.UCORQ,
CAST(POITEM.BLCOD as char(15) ccsid 37) as blcod,
CAST(POMAST.VNDNR as char(15) ccsid 37) as vendor,
CAST(POMAST.PSTTS as char(15) ccsid 37) as pstts,
CAST(VENNAM.VNAME as char(15) ccsid 37) as vname,
CAST(OVERRD.BNAME as char(15) ccsid 37) as bname
FROM POMAST
LEFT OUTER JOIN POITEM ON POMAST.ORDNO = POITEM.ORDNO
LEFT OUTER JOIN OVERRD ON POMAST.ORDNO = OVERRD.ORDNO
LEFT OUTER JOIN VENNAM ON POMAST.VNDNR = VENNAM.VNDNR
WHERE POITEM.ORDNO = @orderNum
CommandText? It usually doesn't matter, but this is an unusual case. Also,WHERE POITEM.ORDNO = @orderNumis correct syntax.poTextBox.Textbefore putting it in your query, because type mismatches will prevent your code from behaving as you expect it to (or just plain cause errors).