Skip to content
Advertisement

SqlException: invalid column name even though it’s not the column

I am trying to insert basic data into my MSSQL database but I keep receiving this error:

My query string is:

I do not understand the exception, it says that column names Common, Bug, sac, sacas are invalid, but I am not using these as column names. I am stating in the INSERT statement that it should use ([Function], Date, Severity, ChangedBy, Changes)"; and insert VALUES VALUES ({0}, {1}, {2}, {3}, {4})", function, date, severity, changedBy, changes) which is common, bug, sac and scas.

These values are strings:

The whole method that gets executed:

Advertisement

Answer

When passing varchar/nvarchar/text values you need to wrap them in single quotes:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement