473,625 Members | 3,353 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.CreateOb ject("ADODB.Rec ordset")
osRecordset.Ope n strSQL, strConnect

Response.Write osRecordSet.Rec ordcount & "<br>"
-------------------

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

Thanks,
Navin
Jul 19 '05 #1
4 4967

"Navin Kulshreshtha" <am*******@hotm ail.com> wrote in message
Response.Write osRecordSet.Rec ordcount
This line always returns -1.


http://www.aspfaq.com/2193

Ray at work
Jul 19 '05 #2
"Navin Kulshreshtha" <am*******@hotm ail.com> wrote in message
news:d1******** *************** ***@posting.goo gle.com...
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.CreateOb ject("ADODB.Rec ordset")
osRecordset.Ope n strSQL, strConnect

Response.Write osRecordSet.Rec ordcount & "<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.Op en strSQL, strConnect

with these:

Set dbConn= Server.CreateOb ject("ADODB.Con nection")
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*******@hotm ail.com> wrote in message
news:d1******** *************** ***@posting.goo gle.com...
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.CreateOb ject("ADODB.Rec ordset")
osRecordset.Ope n strSQL, strConnect

Response.Write osRecordSet.Rec ordcount & "<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.Ope n strSQL, strConnect to
osRecordset.Ope n strSQL, strConnect,1,3
Thats All!

-Nav!d

"Navin Kulshreshtha" <am*******@hotm ail.com> wrote in message
news:d1******** *************** ***@posting.goo gle.com...
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.CreateOb ject("ADODB.Rec ordset")
osRecordset.Ope n strSQL, strConnect

Response.Write osRecordSet.Rec ordcount & "<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
7074
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 working fine in Mozilla but it isn't working in Internet Explorer :( Is this a known bug ? do you have any suggestion without using tables or OnResize event ? Best regards,
1
2401
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 items), then use the total number of daily open items to calculate the percentage to all open items for the month. my first question is how would i be able to capture the current filtered openrecordset and count the records? would i use the
2
2131
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 cannot get it to work today. I've studied both my old and new code and cannot see a reason why it's doing what it is. I've been hammering my head against the wall for three hours now playing around with ever simplified versions of the code to try...
1
2329
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 InitialDirectory will cause the dialog to show files in that directory. However, any further times that the dialog is displayed, the directory that is shown will always be the one initially used regardless of the RestoreDirectory setting. This appears to be...
0
1106
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() renderer1.set_property('activatable', True) renderer1.connect( 'toggled', self.selection, self.list)
3
1283
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. Basically i need to test to see what value is set (where to retrieve the data from) so ive done it like this: If Request.Querystring("id") = "" then TidF=Request.Form("TidF")
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
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 we have to send another system
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.