Classic ASP does not let me return @@ROWCOUNT from SQL SERVER
I have a classic ASP statement that throws the following (via ADO) to SQL Server:
SELECT @@ROWCOUNT AS NoRecords,SP.SpeakerId,SP.Title,SP.FirstName,SP.LastName,SP.Letters,SP.Tags,SP.SpeakerReferenceFROM Speaker SP INNER JOIN Client CL ON CL.ClientId = SP.ClientId WHERE ( ( (SP.Title LIKE '%a%' AND SP.Title <> 'Mr' AND SP.Title <> 'Ms') OR (SP.FirstName LIKE '%a%') OR (SP.LastName LIKE '%a%') OR (SP.Letters LIKE '%a%') ) AND ( (CL.FirstName LIKE '%fay%') OR (CL.LastName LIKE '%fay%') OR (CL.CompanyName LIKE '%fay%') OR (SP.Biography LIKE '%fay%') OR (CL.Email LIKE '%fay%') ) ) ORDER BY SP.FirstName, SP.LastName;
response.write(ALtest("abc123"))Function ALtest(stockCode) Set cmd = Server.CreateObject("ADODB.Command")With cmd ' Set up DB connection to use, set the type of SQL command .ActiveConnection = MyConnectionString .CommandType = adCmdStoredProc .CommandText = "ALtest" .Parameters.Append .CreateParameter("@p_StockCode",adVarChar, adParamInput,50) .Parameters("@p_StockCode") = stockCode set rs = .ExecuteEnd With ALtest= rs(0)set cmd = nothingset rs = nothingend Function
As I said in my original post If you run the code against MY database in SQL Server MS I get NoRecord = 10 (in this particular case).
When I try and execute the SAME statement from Classic ASP (via ADO) it always returns 0 in NoRecords.
This highlights a difference in the way MS handles the statement and ADO handles the statement - I want to know how to get this statement working in Classic ASP so that it returns the correct number of rows.
Open in new window