I\'m calling the code below.
On the line (IDataReader dr = cmd.ExecuteReader()) sql barfs with an Incorrect syntax near \'CompanyUpdate\'.
I notice that you've not set the CommandType to StoredProcedure... I don't know if that's the cause of your problem or not:
cmd.CommandType = CommandType.StoredProcedure;
I've done this so many times myself I can't count.
Tip to trigger your memory when this throws exceptions next time:
Have SQL Query Profiler open while you're running your app. When each command executes, it shows the SQL generated and run on the server side. If the SQL generated begins with sp_executesql
followed by your query then it's being run as a regular query - i.e. cmd.CommandType = CommandType.Text
, if it starts with exec
, chances are it's run as a stored proc. Make sure you're getting the correct SQL generated for the type of query you're trying to run.