473,406 Members | 2,849 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,406 software developers and data experts.

How to count no of record ?

In my store procedure , i will select * from myTable, and I will while-loop
the result by using datareader in vb.net .
Now, Can I know the number of records before I while-loop the resut ??

Nov 21 '05 #1
7 3007
AFAIK, you won't know the number of records. You can change the query to
say:

Select *, Count(*) from myTable which will also give you the count.

hope that helps..
Imran.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
In my store procedure , i will select * from myTable, and I will
while-loop
the result by using datareader in vb.net .
Now, Can I know the number of records before I while-loop the resut ??

Nov 21 '05 #2
CT
Not unless you have the row count returned as a different result set, making
the stored procedure return two results; the row count and the actual rows.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
In my store procedure , i will select * from myTable, and I will
while-loop
the result by using datareader in vb.net .
Now, Can I know the number of records before I while-loop the resut ??

Nov 21 '05 #3
Could you give me a little sample , how to return two result ???
Thanks a lot
"CT" <ca******@spammersgoawaydotnetservices.biz> ¦b¶l¥ó
news:eX**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
Not unless you have the row count returned as a different result set, making the stored procedure return two results; the row count and the actual rows.
--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
In my store procedure , i will select * from myTable, and I will
while-loop
the result by using datareader in vb.net .
Now, Can I know the number of records before I while-loop the resut ??


Nov 21 '05 #4
CT
Sure, do something like this:

SELECT COUNT(*) FROM TableName;
SELECT * FROM TableName

Once results have been returned to the client, read the scalar value in the
first resultset, and move the "real" data in the second resultset using the
NextResult method of the datareader.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:Oe**************@TK2MSFTNGP14.phx.gbl...
Could you give me a little sample , how to return two result ???
Thanks a lot
"CT" <ca******@spammersgoawaydotnetservices.biz> ¦b¶l¥ó
news:eX**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
Not unless you have the row count returned as a different result set,

making
the stored procedure return two results; the row count and the actual

rows.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
> In my store procedure , i will select * from myTable, and I will
> while-loop
> the result by using datareader in vb.net .
> Now, Can I know the number of records before I while-loop the resut ??
>
>
>



Nov 21 '05 #5
why not put the * and count(*) in the same sql so you don't hit the server
twice?

select *, Count(*) from myTable

"CT" <ca******@spammersgoawaydotnetservices.biz> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Sure, do something like this:

SELECT COUNT(*) FROM TableName;
SELECT * FROM TableName

Once results have been returned to the client, read the scalar value in
the first resultset, and move the "real" data in the second resultset
using the NextResult method of the datareader.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:Oe**************@TK2MSFTNGP14.phx.gbl...
Could you give me a little sample , how to return two result ???
Thanks a lot
"CT" <ca******@spammersgoawaydotnetservices.biz> ¦b¶l¥ó
news:eX**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
Not unless you have the row count returned as a different result set,

making
the stored procedure return two results; the row count and the actual

rows.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
> In my store procedure , i will select * from myTable, and I will
> while-loop
> the result by using datareader in vb.net .
> Now, Can I know the number of records before I while-loop the resut ??
>
>
>



Nov 21 '05 #6
disregard my previous msg - I wasn't thinking :(

"CT" <ca******@spammersgoawaydotnetservices.biz> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Sure, do something like this:

SELECT COUNT(*) FROM TableName;
SELECT * FROM TableName

Once results have been returned to the client, read the scalar value in the first resultset, and move the "real" data in the second resultset using the NextResult method of the datareader.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:Oe**************@TK2MSFTNGP14.phx.gbl...
Could you give me a little sample , how to return two result ???
Thanks a lot
"CT" <ca******@spammersgoawaydotnetservices.biz> ¦b¶l¥ó
news:eX**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
Not unless you have the row count returned as a different result set,

making
the stored procedure return two results; the row count and the actual

rows.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
> In my store procedure , i will select * from myTable, and I will
> while-loop
> the result by using datareader in vb.net .
> Now, Can I know the number of records before I while-loop the resut ?? >
>
>



Nov 21 '05 #7
CT
Heck, it's Friday, right? ;-)

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Imran Koradia" <no****@microsoft.com> wrote in message
news:uE**************@TK2MSFTNGP11.phx.gbl...
disregard my previous msg - I wasn't thinking :(

"CT" <ca******@spammersgoawaydotnetservices.biz> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Sure, do something like this:

SELECT COUNT(*) FROM TableName;
SELECT * FROM TableName

Once results have been returned to the client, read the scalar value in

the
first resultset, and move the "real" data in the second resultset using

the
NextResult method of the datareader.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:Oe**************@TK2MSFTNGP14.phx.gbl...
> Could you give me a little sample , how to return two result ???
> Thanks a lot
>
>
> "CT" <ca******@spammersgoawaydotnetservices.biz> ¦b¶l¥ó
> news:eX**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
>> Not unless you have the row count returned as a different result set,
> making
>> the stored procedure return two results; the row count and the actual
> rows.
>>
>> --
>> Carsten Thomsen
>> Enterprise Development with VS .NET, UML, and MSF
>> http://www.apress.com/book/bookDisplay.html?bID=105
>> "Agnes" <ag***@dynamictech.com.hk> wrote in message
>> news:u1**************@TK2MSFTNGP09.phx.gbl...
>> > In my store procedure , i will select * from myTable, and I will
>> > while-loop
>> > the result by using datareader in vb.net .
>> > Now, Can I know the number of records before I while-loop the resut ?? >> >
>> >
>> >
>>
>>
>
>



Nov 21 '05 #8

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

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...
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...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
7
by: hjohnson | last post by:
Within the access environment, I have a table that I'd like to -add a column -place the record number of each record into that column The autonumber is not working for me because I am...
1
by: sparks | last post by:
I have always just got a count on records and put up a box at the top of the entry forms saying something like 1 of 500 and updating it as you got to 500 of 500. I have never thought of this as...
4
by: AccessHunter | last post by:
Hi, I have a table with the type of data as below, sorted as follows, Case (ascending), Loc (ascending) and Transaction Date (ascending). CASE LOC TRANSACTION DATE FACILITY...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.