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)
6 1805
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
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??
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
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
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]
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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 =...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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,...
|
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...
| |