By reading the records and count them. As a datareader is specialized
for reading a result from start to end, there is no way of getting the
number of records in the result without reading them.
If you only want to know the number of records, you should use a count()
expression in the SQL query instead. That way you only get the
information you need in the result instead of a lot of data that you
don't use.
Anuradha wrote:[color=blue]
> Dear Experts
>
> How can I count records in a data reader?
>
>
>
> Thx
>
> Anuradha
>[/color]
In addition to Göran's post, you can use the ExecuteScalar method of the
DataCommand to retrieve the count.
--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"Göran Andersson" <guffa@guffa.co m> wrote in message
news:%23BzIFNFk GHA.1264@TK2MSF TNGP05.phx.gbl. ..[color=blue]
> By reading the records and count them. As a datareader is specialized for
> reading a result from start to end, there is no way of getting the number
> of records in the result without reading them.
>
> If you only want to know the number of records, you should use a count()
> expression in the SQL query instead. That way you only get the information
> you need in the result instead of a lot of data that you don't use.
>
> Anuradha wrote:[color=green]
>> Dear Experts
>>
>> How can I count records in a data reader?
>>
>>
>>
>> Thx
>>
>> Anuradha
>>[/color][/color]
What i mean is I need to check the table and if records found I need to
update another table. I will give a example
Select * from bktrn where EPF='" & text.text & "'
If recodes found then
xxxxxxxxx
end if
how can I do this
Thx
Anuradha
"CT" <carstent@spamm ersgoawayintegr asol.dk> wrote in message
news:OZJpZQFkGH A.5020@TK2MSFTN GP02.phx.gbl...[color=blue]
> In addition to Göran's post, you can use the ExecuteScalar method of the
> DataCommand to retrieve the count.
>
> --
> Carsten Thomsen
> Communities - http://community.integratedsolutions.dk
> ---------
> Voodoo Programming: Things programmers do that they know shouldn't work[/color]
but[color=blue]
> they try anyway, and which sometimes actually work, such as recompiling
> everything. (Karl Lehenbauer)
> ---------
> "Göran Andersson" <guffa@guffa.co m> wrote in message
> news:%23BzIFNFk GHA.1264@TK2MSF TNGP05.phx.gbl. ..[color=green]
> > By reading the records and count them. As a datareader is specialized[/color][/color]
for[color=blue][color=green]
> > reading a result from start to end, there is no way of getting the[/color][/color]
number[color=blue][color=green]
> > of records in the result without reading them.
> >
> > If you only want to know the number of records, you should use a count()
> > expression in the SQL query instead. That way you only get the[/color][/color]
information[color=blue][color=green]
> > you need in the result instead of a lot of data that you don't use.
> >
> > Anuradha wrote:[color=darkred]
> >> Dear Experts
> >>
> >> How can I count records in a data reader?
> >>
> >>
> >>
> >> Thx
> >>
> >> Anuradha
> >>[/color][/color]
>
>[/color]
Select count(*) from bktrn where EPF='" & text.text & "'
The query will return a single record with a single field, that contains
the number of records that matched the condition.
Anuradha wrote:[color=blue]
> What i mean is I need to check the table and if records found I need to
> update another table. I will give a example
>
>
>
> Select * from bktrn where EPF='" & text.text & "'
>
>
>
> If recodes found then
>
> xxxxxxxxx
>
> end if
>
>
>
> how can I do this
>
>
> Thx
> Anuradha
> "CT" <carstent@spamm ersgoawayintegr asol.dk> wrote in message
> news:OZJpZQFkGH A.5020@TK2MSFTN GP02.phx.gbl...[color=green]
>> In addition to Göran's post, you can use the ExecuteScalar method of the
>> DataCommand to retrieve the count.
>>
>> --
>> Carsten Thomsen
>> Communities - http://community.integratedsolutions.dk
>> ---------
>> Voodoo Programming: Things programmers do that they know shouldn't work[/color]
> but[color=green]
>> they try anyway, and which sometimes actually work, such as recompiling
>> everything. (Karl Lehenbauer)
>> ---------
>> "Göran Andersson" <guffa@guffa.co m> wrote in message
>> news:%23BzIFNFk GHA.1264@TK2MSF TNGP05.phx.gbl. ..[color=darkred]
>>> By reading the records and count them. As a datareader is specialized[/color][/color]
> for[color=green][color=darkred]
>>> reading a result from start to end, there is no way of getting the[/color][/color]
> number[color=green][color=darkred]
>>> of records in the result without reading them.
>>>
>>> If you only want to know the number of records, you should use a count()
>>> expression in the SQL query instead. That way you only get the[/color][/color]
> information[color=green][color=darkred]
>>> you need in the result instead of a lot of data that you don't use.
>>>
>>> Anuradha wrote:
>>>> Dear Experts
>>>>
>>>> How can I count records in a data reader?
>>>>
>>>>
>>>>
>>>> Thx
>>>>
>>>> Anuradha
>>>>[/color][/color][/color]
Comment