Forum Moderators: open

Message Too Old, No Replies

Returning a record count from a command object

ASP / SQL-Server

         

daveo

8:46 am on Jul 27, 2004 (gmt 0)

10+ Year Member



I'm trying to establish the record count for a recordset returned by using a command object. The command object which calls a stored procedure, which in turn may fetch a set of results from a database. I keep getting a -1 value for the record count, however I try to force a patricular cursor to be employed. Can anybody help?

Thanks in advance.......

var oConn, oRS, oCmd;
oConn = Server.CreateObject('ADODB.Connection');
oConn.ConnectionString = Application('myDatabaseConnect');
oConn.Open;
oRS = Server.CreateObject('ADODB.RecordSet');
oCmd = Server.CreateObject('ADODB.Command');
oCmd.ActiveConnection = oConn;
oCmd.CommandText = 'sp_search_results;
oCmd.CommandType = adCmdStoredProc;
oParam = oCmd.CreateParameter('@search_term', adVarChar, adParamInput, 50, searchTerm);
oCmd.Parameters.Append(oParam); oParam = oCmd.CreateParameter('@version',adVarChar, adParamInput, 50, 'fee_earners_no_trainees'); oCmd.Parameters.Append(oParam);
oRS.Open(oCmd);

noRecords = oRS.RecordCount;

oRS.Close;
oConn.Close;

JuniorHarris

7:13 pm on Jul 27, 2004 (gmt 0)

10+ Year Member



I didn't look at your problem very close, but I did pull this from some code I had...

objConn.cursorlocation = 3 'enables rs.RecordCount