RecordCount returns -1

M

MasterChief

I am trying to connect to a database that is created by a program we
use called TrackIt. When I try to use the RecordCount statement it
always returns -1. I have looked up all the reasons why -1 would come
back and I thought I had fixed everything but it still is having
problems. Here is the part of the code for RecordCount.

Session("dsn") = dsn
Session("dbuser") = dbuser
Session("dbpass") = dbpass

Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open dsn, dbuser, dbpass

rs.Open sql, Conn, adOpenStatic, , adCmdTable

Response.write "<BR>Supports Approx Position: " &
rs.Supports(adApproxPosition) & "<BR>"
intRecordCnt = rs.RecordCount
Response.write "<BR>RecordCount:" & intRecordCnt & "<BR>"
 
J

Jens Peter Karlsen [FP-MVP]

Where is your SQL Statement?

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
M

MasterChief

Here you go. This was what is above all of the code I pasted before.

<HTML><HEAD></HEAD><BODY>
<%

dsn = "Trackit"
dbuser = "sa"
dbpass = "*******"
sql = "SELECT WOID, WO_NUM, TASK FROM TRACKIT65_DATA.dbo.TASKS TASKS
WHERE (TASKS.COMPLETED Is Null) AND (TASKS.RESPONS Is Null)"
 
J

Jens Peter Karlsen [FP-MVP]

Try changing it to:
sql = "SELECT COUNT(*) AS intRecordCnt, TASKS.WOID, TASKS.WO_NUM,
TASKS.TASK FROM TRACKIT65_DATA.dbo.TASKS TASKS WHERE (TASKS.COMPLETED
Is Null) AND (TASKS.RESPONS Is Null)"

Change the rest accordingly.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
S

Stefan B Rusynko

And make sure you have also defined a value for adOpenStatic and adCmdTable in:
rs.Open sql, Conn, adOpenStatic, , adCmdTable

Unless you are including adovbs.inc in you page Set

adOpenStatic = 3
Const adCmdTable = &H0002

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Try changing it to:
| sql = "SELECT COUNT(*) AS intRecordCnt, TASKS.WOID, TASKS.WO_NUM,
| TASKS.TASK FROM TRACKIT65_DATA.dbo.TASKS TASKS WHERE (TASKS.COMPLETED
| Is Null) AND (TASKS.RESPONS Is Null)"
|
| Change the rest accordingly.
|
| Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
|
|
| On 26 Oct 2005 10:56:24 -0700, "MasterChief" <[email protected]>
| wrote:
|
| >Here you go. This was what is above all of the code I pasted before.
| >
| ><HTML><HEAD></HEAD><BODY>
| ><%
| >
| >dsn = "Trackit"
| >dbuser = "sa"
| >dbpass = "*******"
| >sql = "SELECT WOID, WO_NUM, TASK FROM TRACKIT65_DATA.dbo.TASKS TASKS
| >WHERE (TASKS.COMPLETED Is Null) AND (TASKS.RESPONS Is Null)"
| >
| >
| >
| >Jens Peter Karlsen [FP-MVP] wrote:
| >> Where is your SQL Statement?
| >>
| >> Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
| >>
| >> On 26 Oct 2005 06:53:25 -0700, "MasterChief" <[email protected]>
| >> wrote:
| >>
| >> >I am trying to connect to a database that is created by a program we
| >> >use called TrackIt. When I try to use the RecordCount statement it
| >> >always returns -1. I have looked up all the reasons why -1 would come
| >> >back and I thought I had fixed everything but it still is having
| >> >problems. Here is the part of the code for RecordCount.
| >> >
| >> >Session("dsn") = dsn
| >> >Session("dbuser") = dbuser
| >> >Session("dbpass") = dbpass
| >> >
| >> >Set Conn = Server.CreateObject("ADODB.Connection")
| >> >Set rs = Server.CreateObject("ADODB.RecordSet")
| >> >Conn.Open dsn, dbuser, dbpass
| >> >
| >> >rs.Open sql, Conn, adOpenStatic, , adCmdTable
| >> >
| >> >Response.write "<BR>Supports Approx Position: " &
| >> >rs.Supports(adApproxPosition) & "<BR>"
| >> >intRecordCnt = rs.RecordCount
| >> >Response.write "<BR>RecordCount:" & intRecordCnt & "<BR>"
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top