I have this really simple trouble I can’t seem to overcome.
I’m trying to execute this code lines with sql ce :
SqlCeCommand comSelect = new SqlCeCommand("SELECT * FROM Items WHERE barcode = '@barcode'", conn);
comSelect.Parameters.Add(new SqlCeParameter("barcode", System.Data.SqlDbType.NVarChar, 100)).Value = barC;
For some weird reason – it always comes back as empty- i.e not results found. If I put the parameter value by myself in the query string, like so:
SELECT * FROM Items WHERE barcode = '123ABC'
then it works perfect. I will add that the column IS a NVarChar.
Any idea of why this isn’t working?
Try using this:
Instead of what you have. Please do note the lack of quotes in
@barcode.