[Solved] SQL code error in C#


The SQL statement is not the problem (you are able to execute it in SQL manager) and neither is it the call to AddWithValue because that won’t throw an ArgumentException based on the cause in mentioned in the exception message. So it must be something else. That leaves a constant and an expression using the string "ID"as the argument for the parameter ColumnName

tblListing.Rows[0]["ID"]

The documentation for the index has the following documentation for when it will throw an ArgumentException

The column specified by columnName cannot be found.

So your error is in that expression. The DataTable tblListing has no column named “ID”

solved SQL code error in C#