Skip to content
Advertisement

System.Data.SqlClient.SqlException (0x80131904): Invalid column name

I am getting this error while trying to execute the attached code. Please help. I am getting values as list array in controller method successfully but when I try to read data from sql database I am getting error.

Controller method:

Execption:-

Advertisement

Answer

Since you are using inline SQL, every value within dogCSV string that’s comma separated needs a single quote around it. For instance, if dogCSV has "account2,someotheraccount", this won’t work it needs to be "'account2','someotheraccount'".

If you don’t that definitely would be the issue.

EDIT: Build dogCSV like this:

The way it’s built now will not put quotes around it.

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