473,503 Members | 12,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't get recordcount property to work!!

Hi folks, I'm opening a recordset with a SQL statement and then trying
to use the .RecordCount property to count the number of rows in the
recordset. For some reason, it is always returning -1. Here's the code
(I have left out the details for the connection string):

-------------------
strSQL = "SELECT * from orders"
strConnect = [details removed]
Set osRecordSet = Server.CreateObject("ADODB.Recordset")
osRecordset.Open strSQL, strConnect

Response.Write osRecordSet.Recordcount & "<br>"
-------------------

This last line always returns -1. Please help!!

Thanks,
Navin
Jul 19 '05 #1
4 4961

"Navin Kulshreshtha" <am*******@hotmail.com> wrote in message
Response.Write osRecordSet.Recordcount
This line always returns -1.


http://www.aspfaq.com/2193

Ray at work
Jul 19 '05 #2
"Navin Kulshreshtha" <am*******@hotmail.com> wrote in message
news:d1**************************@posting.google.c om...
Hi folks, I'm opening a recordset with a SQL statement and then trying
to use the .RecordCount property to count the number of rows in the
recordset. For some reason, it is always returning -1. Here's the code
(I have left out the details for the connection string):

-------------------
strSQL = "SELECT * from orders"
strConnect = [details removed]
Set osRecordSet = Server.CreateObject("ADODB.Recordset")
osRecordset.Open strSQL, strConnect

Response.Write osRecordSet.Recordcount & "<br>"
-------------------

This last line always returns -1. Please help!!


I'm just taking a stab in the dark, but I usually create a recordset using
the Execute method of the Connection object. Maybe try doing that instead?

Replace this line:

osRecoredset.Open strSQL, strConnect

with these:

Set dbConn= Server.CreateObject("ADODB.Connection")
dbConn.Open strConnect
Set osRecordset = dbConn.Execute(strSQL, , adCmdText)

And then don't forget to close the dbConn (and set to Nothing) when done.

See if that works?

Good luck.
Peter Foti
Jul 19 '05 #3
"Navin Kulshreshtha" <am*******@hotmail.com> wrote in message
news:d1**************************@posting.google.c om...
Hi folks, I'm opening a recordset with a SQL statement and then trying
to use the .RecordCount property to count the number of rows in the
recordset. For some reason, it is always returning -1. Here's the code
(I have left out the details for the connection string):

-------------------
strSQL = "SELECT * from orders"
strConnect = [details removed]
Set osRecordSet = Server.CreateObject("ADODB.Recordset")
osRecordset.Open strSQL, strConnect

Response.Write osRecordSet.Recordcount & "<br>"
-------------------

This last line always returns -1. Please help!!


Just read some more on this... if a forward-only cursor is being used,
then -1 is returned. I suspect that is your problem. You can find some
good info on this at:
http://www.devguru.com/Technologies/...cordcount.html

And for general ADO:
http://www.devguru.com/Technologies/...ado_intro.html

Regards,
Peter Foti

Jul 19 '05 #4
Hi,

Just Change osRecordset.Open strSQL, strConnect to
osRecordset.Open strSQL, strConnect,1,3
Thats All!

-Nav!d

"Navin Kulshreshtha" <am*******@hotmail.com> wrote in message
news:d1**************************@posting.google.c om...
Hi folks, I'm opening a recordset with a SQL statement and then trying
to use the .RecordCount property to count the number of rows in the
recordset. For some reason, it is always returning -1. Here's the code
(I have left out the details for the connection string):

-------------------
strSQL = "SELECT * from orders"
strConnect = [details removed]
Set osRecordSet = Server.CreateObject("ADODB.Recordset")
osRecordset.Open strSQL, strConnect

Response.Write osRecordSet.Recordcount & "<br>"
-------------------

This last line always returns -1. Please help!!

Thanks,
Navin

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
7043
by: jonjon | last post by:
Hi, I want to be able to define the right property of my absolute positionned elements... for example if a button is 50px left and 150px right, it will resize when the page is resized. This is...
1
2392
by: JMCN | last post by:
hello- i have created a tabular form using records from a specific query. then users will filter out the specific data. the next step is to take the count of the current records (daily open...
2
2119
by: Andy_Khosravi | last post by:
This is probably one of the most simple things to do in VB, yet somehow I've messed it up and cannot get it to work properly. I've used it dozens of times in the past, but for whatever reason I...
1
2313
by: Johann Blake | last post by:
A number of posts have indicated developers having problem getting an OpenFileDialog to startup in a specific directory when the dialog is shown. The first time you show the dialog, the...
0
1102
by: sapo | last post by:
This is my code: def list(self): tree = self.principal.get_widget("list") self.list = gtk.ListStore(bool,str) self.options = renderer1 = gtk.CellRendererToggle()...
3
1278
by: Luke - eat.lemons | last post by:
Sorry for the post in this NG but im short on time to get this working and i haven't seem to of got a response anywhere else. Im pretty new to asp so all light on this question would be great. ...
0
7212
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
7470
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
5604
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,...
1
5026
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...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.