Hi,
Is there a way to get the number of rows that the ExecuteReader has fetched
without iterating through with the Read(). I tried RecordsAffected but that
returns -1 all the time. HasRows only tells you that there is 1 or more
rows, but it does not tell you how many.
TIA
Roy 7 7448
Roy,
No, there is not. The reader typically will not know how many rows are
returned. You either have to include it as a part of the query (have a
column with the count, but that is not efficient), or count the number of
iterations.
You could also issue a second, separate select with the same parameters,
but that introduces extra, undesirable overhead.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Roy Gourgi" <ro***@videotro n.ca> wrote in message
news:L1******** *********@wagne r.videotron.net ... Hi,
Is there a way to get the number of rows that the ExecuteReader has fetched without iterating through with the Read(). I tried RecordsAffected but that returns -1 all the time. HasRows only tells you that there is 1 or more rows, but it does not tell you how many.
TIA Roy
Hi Roy,
One possible way is using batch SQL statements, first statement to
count. Use DataReader.Next Result to advance to the next result.
Thi
Thanks Nicholas,
As it turns out I had to process the info in the datareader so counting the
number of iterations is the way to go for my problem.
Funny though, in Visual FoxPro you could do everything I am asking for
without a sweat. I am wondering why they did not transport this to VS.
Thanks
Roy
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** *********@TK2MS FTNGP10.phx.gbl ... Roy,
No, there is not. The reader typically will not know how many rows are returned. You either have to include it as a part of the query (have a column with the count, but that is not efficient), or count the number of iterations.
You could also issue a second, separate select with the same parameters, but that introduces extra, undesirable overhead.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Roy Gourgi" <ro***@videotro n.ca> wrote in message news:L1******** *********@wagne r.videotron.net ... Hi,
Is there a way to get the number of rows that the ExecuteReader has fetched without iterating through with the Read(). I tried RecordsAffected but that returns -1 all the time. HasRows only tells you that there is 1 or more rows, but it does not tell you how many.
TIA Roy
Thanks Truong, for now I think I will use the iterations method.
Roy
"Truong Hong Thi" <th*****@gmail. com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com... Hi Roy,
One possible way is using batch SQL statements, first statement to count. Use DataReader.Next Result to advance to the next result.
Thi
Hi,
This is not a limitation of VS, not even .NET . It's the way SQL server
serve a server side cursor.
BTW, the very same thing apply to output and return parameters.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Roy Gourgi" <ro***@videotro n.ca> wrote in message
news:oQ******** *********@wagne r.videotron.net ... Thanks Nicholas,
As it turns out I had to process the info in the datareader so counting the number of iterations is the way to go for my problem.
Funny though, in Visual FoxPro you could do everything I am asking for without a sweat. I am wondering why they did not transport this to VS.
Thanks Roy
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:%2******** *********@TK2MS FTNGP10.phx.gbl ... Roy,
No, there is not. The reader typically will not know how many rows are returned. You either have to include it as a part of the query (have a column with the count, but that is not efficient), or count the number of iterations.
You could also issue a second, separate select with the same parameters, but that introduces extra, undesirable overhead.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Roy Gourgi" <ro***@videotro n.ca> wrote in message news:L1******** *********@wagne r.videotron.net ... Hi,
Is there a way to get the number of rows that the ExecuteReader has fetched without iterating through with the Read(). I tried RecordsAffected but that returns -1 all the time. HasRows only tells you that there is 1 or more rows, but it does not tell you how many.
TIA Roy
Hi Ignacio,
Who makes SQL? I thought that it was Microsoft!
What do you mean when you say that the same applies to output and return
parameters?
Roy
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:O3******** *******@TK2MSFT NGP09.phx.gbl.. . Hi,
This is not a limitation of VS, not even .NET . It's the way SQL server serve a server side cursor.
BTW, the very same thing apply to output and return parameters.
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Roy Gourgi" <ro***@videotro n.ca> wrote in message news:oQ******** *********@wagne r.videotron.net ... Thanks Nicholas,
As it turns out I had to process the info in the datareader so counting the number of iterations is the way to go for my problem.
Funny though, in Visual FoxPro you could do everything I am asking for without a sweat. I am wondering why they did not transport this to VS.
Thanks Roy
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:%2******** *********@TK2MS FTNGP10.phx.gbl ... Roy,
No, there is not. The reader typically will not know how many rows are returned. You either have to include it as a part of the query (have a column with the count, but that is not efficient), or count the number of iterations.
You could also issue a second, separate select with the same parameters, but that introduces extra, undesirable overhead.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Roy Gourgi" <ro***@videotro n.ca> wrote in message news:L1******** *********@wagne r.videotron.net ... Hi,
Is there a way to get the number of rows that the ExecuteReader has fetched without iterating through with the Read(). I tried RecordsAffected but that returns -1 all the time. HasRows only tells you that there is 1 or more rows, but it does not tell you how many.
TIA Roy
Hi,
"Roy Gourgi" <ro***@videotro n.ca> wrote in message
news:b0******** **********@wagn er.videotron.ne t... Who makes SQL? I thought that it was Microsoft!
Well, last time I checked that was true :) , so what?
What do you mean when you say that the same applies to output and return parameters?
That you do not have access to them until you end iterating in the returned
rows, I know it was not in the original thread (any mention to output
params ) I mixed two posts I was reading/answering at the same time.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Hokes |
last post by:
Hi All,
We're using the 1.1. Framework against SQL Server 2000, and are having a
strange issue where we don't get errors back from the stored procedure, i.e.
the exception never gets thrown.
The scenario is this:
1.) Set up SqlConnection and SqlCommand
2.) Set SqlDataReader equal to the return value from
SqlCommand.ExecuteReader
|
by: Mark |
last post by:
It appears that you can only retrieve an Output parameter from a SQL Server
stored procedure when using the ExecuteNonQuery of the SqlCommand class, and
cannot use the ExecuteReader() method. In the code sample below, it bombs
on the line with three *** when using the ExecuteReader, but works just fine
when you use the ExecuteNonQuery. When using the ExecuteReader, the
Output parameter appears to return a value of Null. The stored...
|
by: BuddyWork |
last post by:
Does anyone know if there are any articles explaining how
I could debug into SqlCommand.ExecuteReader so I can see
why I am getting a particular error.
thanks
|
by: BuddyWork |
last post by:
Hello,
The problem is that when using SqlCommand.ExecuteReader
and the SQL statement raises an error of severity of 16
then ExecuteReader throws an exception, when you use
OdbcCommand.ExecuteReader the exception is not raised but
when you call Read() method of the OdbcDataReader you then
get the exception which is correct, basically SqlClient
does not let you call the Read method, the main problem is
that if run a Sql statement of say
|
by: orencs |
last post by:
Hello,
I am using Microsoft.Practices.EnterpriseLibrary.Data.
I am running the following
sqlCommand = "SELECT var1 FROM table1 WHERE var2 IN (4,5,6) ; SELECT
var3 FROM table2 WHERE var2 IN (4,5,6)";
IDataReader dataReader = db.ExecuteReader(dbCommandWrapper); while
| |
by: MattB |
last post by:
I'm trying to implement an example I found for displaying images stored in a
SQL database. The example code looks like this (in page_load):
Dim connstr As String = "Integrated Security=SSPI;Initial
Catalog=Northwind;Data Source=SERVER\netsdk"
Dim cnn As New SqlConnection(connstr)
Dim cmd As New SqlCommand
("select * from images where id=" & Request.QueryString("id"), cnn)
cnn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
|
by: phil |
last post by:
Hi,
With the code below, i get the error:
ExecuteReader: Connection property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ExecuteReader:
Connection property has not been initialized.
|
by: Robert Bravery |
last post by:
HI all,
Whats the differe between useing Executereader() and
Beginexecutereader()...endexecutereader() for asyncronys running of a SP
Thanks
Robert
|
by: fniles |
last post by:
I am using OLEDBDataReader to read from an Access database.
I have 4 data source where I get my data from, and each data source is in
its own thread.
When receiving data, if it is a new commodity I am need to read from the
database.
Since I can receive data from different data source at the same time, it is
possible that I read from the database at the same time.
|
by: fniles |
last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection).
I read using DataAdapter and DataSet, not DataReader.
When many people try to access the database at the same time, I get the
error "ExecuteReader requires an open and available Connection. The
connection's current state is Open, Executing." I do not use ExecuteReader,
why the error says ExecuteReader. What does it mean ?
When I get this error, is there a way for me...
|
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...
| |
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,...
|
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |