The comments are correct but here is a bit of explanation as to why that is the case.
Both errors;
Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near '@Anum'.
and
Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near '164360'.
are actually quite descriptive and pinpoint where the issue is. Usually in a situation like this an error is highlighting a problem just before the word or phrase in an error description in these cases the @Anum
parameter and the 164360
value. If we follow this through the previous character in both cases is an open bracket (
.
Unlike functions in T-SQL, Stored Procedures do not require brackets around their parameters and doing so will raise an error (like the ones above) to correct this remove the brackets from both statements.
With named parameters;
EXEC update_allocation @Anum='164360', @mTeam='5', @Team='9', @Perc='14', @Bill=140000, @Mons=164360
Without named parameters;
EXEC update_allocation '164360', '5' ,'9' ,'14' ,140000 ,164360
Either method is acceptable syntax but personally I find it more useful to use the named parameter approach as that allows you to pick and choose what parameters to pass and even exclude ones that have defaults. You can still do this with the nameless approach but ordinal position of the values is more important.
@sean-lange makes a valid point here about SQL Injection vulnerability, consider using the ADODB.Command
object to execute stored procedures rather then just calling the Execute()
method on a ADODB.Connection
object.
Here is an example of calling Stored Procedures using Classic ASP and the ADODB.Command
object.