The data types text and varchar are incompatible in the equal to operator in C#

You can’t compare text to varchar, but as an answer to anyone in the future with this problem simply convert the text column to varchar for the query.

SELECT * FROM  EmployeeTable WHERE CONVERT(VARCHAR, empname) = '" + comboBox1.Text + "' ;";

Always use parameters

SELECT * FROM  EmployeeTable WHERE CONVERT(VARCHAR, empname) = @comboBox";

Leave a Comment