System.Data.Sqlclient.Sqlexception: Line1 incorrect syntax ...
- by marocanu2001
Given a SqlConnection, a SqlCommand if you need to execute a stored procedure it is enough to specify the stored procedure name as the CommandText and it will work.
Now the surprise is that if you also add parametres, you get this creepy error: SqlException: Line 1 incorrect syntax near [storedProcedureName].
The quick fix is to specify the CommandType to be StoredProcedure.