I've looked all over the internet to try and answer this but haven't had any luck. I imagine this is simple mistake on my end but cannot for the life of me determine what it is.
var queryString1 = "SELECT * FROM Product_Table WHERE CustomerInvoice='@custInvSel';";
SqlCommand comm1 = new SqlCommand(queryString1, conn);
comm1.Parameters.AddWithValue("@custInvSel", customerInvoiceSelected);
Basically the above code does not return any data whatsoever, despite the data being present. When the code reads
var queryString1 = "SELECT * FROM Product_Table WHERE CustomerInvoice='"+customerInvoiceSelected+"';";
SqlCommand comm1 = new SqlCommand(queryString1, conn);
Everything works fine. No errors are thrown in either case which has stumped me. It just seems with parameters the query mixes up everything.
The query is executed in both cases identically.
Any help or experience would be greatly appreciated. Thank you for your time!
var queryString1 = $"SELECT * FROM Product_Table WHERE CustomerInvoice='{customerInvoiceSelected}';";