I\'m trying to secure some legacy code written in what I guess is VB or asp(Not really sure if there is a difference). When I try to execute the statement the page gets an i
When using a CommandType of adCmdText the placeholder expected by ADODB is ? and trying to passed named parameters like @fy in the CommandText will fail. It is an unfortunate failing in ADODB that
countCmd.NamedParameters = True
only works with a CommandType of adCmdStoredProc and only with certain providers.
However there is a simple workaround for SQL Server (and possibly other providers depending on what they support) which is to build the named parameters in the CommandText like so;
countCmd.commandText = _
"DECLARE @fy AS VARCHAR(255);" & vbCrLf & _
"SET @fy = ?;" & vbCrLf & _
"SELECT COUNT(*) FROM [table1] WHERE FY=@fy;"
ADO parameterised query not returning any result
ADODB.Parameters error '800a0e7c' Parameter object is improperly defined. Inconsistent or incomplete information was provided