Invalid Column Name | C#

Your WHERE clause here:

WHERE KarakterSoort = Defensive

compares the value in the KarakterSoort column to the value in the Defensive column.

Is that really what you want???

Quite possibly, you want to compare to a string literal – then you need to put this into single quotes like this:

WHERE KarakterSoort = 'Defensive'

Now you’re selecting all rows where the KarakterSoort column contains the value Defensive

Or if you might want compare to some other value in the future – use a parameter in your query string:

WHERE KarakterSoort = @DesiredValue

and declare it

cmd.Parameters.Add("@DesiredValue", SqlDbType.VarChar, 100);

and set its value before your run the command:

cmd.Parameters["@DesiredValue"].Value = "Defensive";

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top