473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

record count shows value -1

I have to take values from two tables with single sql statement.


SQl = SELECT MemAccounts.MemberID,COUNT(MemAccounts.MemberID) AS Total, Membership.First_Name, Membership.Last_Name FROM MemAccounts, Membership WHERE MemAccounts.IntroduceeID <> 0 AND Membership.IsAgent = 1 AND MemAccounts.MemberID = Membership.MemberID AND MemAccounts.TransDate BETWEEN '" &x_FromDate& "' AND '" &x_ToDate& "' GROUP BY MemAccounts.MemberID, Membership.First_Name, Membership.Last_Name ORDER BY Total DESC


i got the correct output in Query Analyser but while running the form there is no output. Record Count is -1.(its not counting the records)
Mar 2 '08 #1
6 1805
idsanjeev
241 100+
Hi neenaprasad
you already know that if your sql statement is run then problems in scripts so please post that or attached file for find out whats is the problems

Thanks
Regards
Mar 2 '08 #2
Set x_FromDate = request.QUERYSTRING("x_FromDate")
If isdate(x_fromDate) then
x_FromDate = CDate(x_FromDate) 'Request.Form("x_FromDate")
end if

Set x_ToDate = request.QUERYSTRING("x_ToDate")
If isdate(x_ToDate) then
x_ToDate = CDate(x_ToDate)'Request.Form("x_FromDate")
End If

If x_FromDate = "" Then
'x_FromDate = DateTime.Today;
'x_ToDate = ""
x_FromDate = Month(Now()) & "/" & "1" & "/" & Year(Now())
x_ToDate = Month(Now()) & "/" & Day(Now()) & "/" & Year(Now())
End If


StrSql = "SELECT MemAccounts.MemberID,COUNT(MemAccounts.MemberID) as Total, Membership.First_Name, Membership.Last_Name FROM MemAccounts, Membership WHERE MemAccounts.IntroduceeID <> 0 AND Membership.IsAgent = 1 AND MemAccounts.MemberID = Membership.MemberID AND MemAccounts.TransDate BETWEEN '" &x_FromDate& "' AND '" &x_ToDate& "' GROUP BY MemAccounts.MemberID, Membership.First_Name, Membership.Last_Name ORDER BY Total DESC "

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open StrSql, conn, 1, 2
nTotalRecs = rs.RecordCount

%>
<%=x_FromDate%>
<%=x_ToDate%>
<%=rs.RecordCount%>


In query analyser it is getting the correct output but in asp form record count is -1. If i remove the count from the above query the output is correct but MemberID is repeating. I need to count out how many times the MemberID occured in the MemAccounts table satisfying the condition..

Can u help me??
Mar 3 '08 #3
DrBunchman
979 Expert 512MB
Hi neenaprasad,

You don't need to use a recordset object recordcount property because you've already included a count in your query. You've assigned the name Total to your count in the query so simply output that:

<%=rs("Total")%>

The reason that the recordcount is returning -1 is because of the type of cursor you are using with your recordset. The default is adOpenForwardOnly which does not allow the recordcount property. For a fuller explanation of the cursor and how you can change it (very easy to do!) try

http://www.w3schools.com/ado/ado_ref_recordset.asp

or

http://www.google.co.uk/search?hl=en...nG=Search&meta=

I hope this helps,

Dr B
Mar 3 '08 #4
jhardman
3,406 Expert 2GB
I have to take values from two tables with single sql statement.


SQl = SELECT MemAccounts.MemberID,COUNT(MemAccounts.MemberID) AS Total, Membership.First_Name, Membership.Last_Name FROM MemAccounts, Membership WHERE MemAccounts.IntroduceeID <> 0 AND Membership.IsAgent = 1 AND MemAccounts.MemberID = Membership.MemberID AND MemAccounts.TransDate BETWEEN '" &x_FromDate& "' AND '" &x_ToDate& "' GROUP BY MemAccounts.MemberID, Membership.First_Name, Membership.Last_Name ORDER BY Total DESC


i got the correct output in Query Analyser but while running the form there is no output. Record Count is -1.(its not counting the records)
Do you have any indication that you are connecting to the db? What is your connection string? Do you get any error when you connect?

Jared
Mar 5 '08 #5
DrBunchman
979 Expert 512MB
This thread was reposted (with a lot more detail it has to be said) by the OP here:

http://www.thescripts.com/forum/thread777769.html

Dr B
Mar 5 '08 #6
Have u set your cursortype ?
just try out this

rs.open SQl,con,3

i got the correct output in Query Analyser but while running the form there is no output. Record Count is -1.(its not counting the records)[/quote]
Mar 6 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
3
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
1
by: Ryan | last post by:
I've got a problem I have't run up against before. I generally test for an empty recordset using BOF and EOF. Today, for the first time I ran into a problem where my recordset shows BOF and EOF =...
1
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the...
2
by: salih ataoz | last post by:
in visual basic 6 rst.recordcount shows us how many records are there in rst but in studio .net i dont konw ho to learn recordcount the code is like this cnn.Open() Dim cmd As OleDbCommand...
7
by: Mike | last post by:
I have a form where I have turned off the default navigation buttons. I then created my own. This works fine. The only questions that I have is on the default navigation buttons it shows total...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
2
by: John | last post by:
Hi I am using the below statement; Me.MyTableAdapter.Fill(Me.MyDataSet.tblMyTable) How can I now check the record count of the data table and specifically if the record count returned by...
2
by: dmne05974 | last post by:
As a novice in Access i am currently writing a database to track certain financial information for a non-profit organisation. As part of the funding they have to monitor age ranges and ethnic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.