1 Replies - 2565 Views - Last Post: 21 May 2009 - 04:53 AM Rate Topic: -----

#1 Saludalabs  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 5
  • Joined: 07-April 09

rs.RecordCount and Rs.PageCount returns -1

Post icon  Posted 19 May 2009 - 10:04 AM

This web application was written in jscript ASP for a Windows Server 2000, and some old SQL database server.

Development Server
Windows Server 2008 with SQL server 2005.

Live servers:
Windows Server 2003, SQL 2005



Problem: This is happens on the local development and live servers. The paging funciton is not working rs.RecordCount and rs.PageCount returns a -1


Question: Does SQL 2005 support rs.RecordCount and rs.PageCount? If it does, is this a problem with the connection string, or server settings? or maybe my code below:


Thanks
David
david@saludalabs.com



// This is jscript not vbscript
var connect;

//create my sql string connections, this works on all pages except the ones that use RecordCount and PageCount
var dbCon = "Provider=SQLOLEDB;Data Source = webdev;Initial Catalog=Assistant;User ID=user;Password=@******;";

  connect = Server.CreateObject("ADODB.Connection");
  connect.Open(dbCon);

var cmd = Server.CreateObject("ADODB.Command");

//job_result4 is a stored procedure in the database
 cmd.CommandText = "job_result4";
 cmd.Parameters.Append(cmd.CreateParameter("userid", adVarchar, adParamInput, 50, Session("Rights")));




// I attempt to currect the problem here with no luck
//cmd.CommandType = adCmdStoredProc;






cmd.ActiveConnection = connect;

var rs = Server.CreateObject("adodb.recordset");

rs=cmd.Execute();





//Problem error later down in the code.  
rs.PageSize=20;
np=rs.PageCount;
if (np = -1)
{
  //np = 1;
}
Response.Write(rs.RecordCount);

if (np>0)
{

//cp is current position
if (cp>np)
 cp=np;
 rs.AbsolutePage=cp;
  nx=20;

if (cp==(np-1))
 nx=rs.RecordCount-cp*20;
j=0;




Is This A Good Question/Topic? 0
  • +

Replies To: rs.RecordCount and Rs.PageCount returns -1

#2 Saludalabs  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 5
  • Joined: 07-April 09

Re: rs.RecordCount and Rs.PageCount returns -1

Posted 21 May 2009 - 04:53 AM

I have figure out this solution. The cursor location needs to be set. connect.CursorLocation=3 just before the connect.open..

Thanks all
Saludalabs
Was This Post Helpful? 1

Page 1 of 1