|
 |
aspx_beginners thread: finding out if a datareader is empty
Message #1 by "Greg Partin" <GPartin@c...> on Mon, 10 Jun 2002 07:58:03 -0700
|
|
how do i find out if a datareader is empty? i can't seem to find a
method or property that would tell me this.
thanks!
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
Message #2 by "Steven A Smith" <ssmith@a...> on Mon, 10 Jun 2002 11:05:35 -0400
|
|
Use this:
if (dr.Read())
// do stuff
else
// if it was empty
or just
while(dr.Read())
{
// process rows
}
Steve
----- Original Message -----
From: "Greg Partin" <GPartin@c...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Monday, June 10, 2002 10:58 AM
Subject: [aspx_beginners] finding out if a datareader is empty
> how do i find out if a datareader is empty? i can't seem to find a
> method or property that would tell me this.
>
> thanks!
>
> Greg Partin
> Software Engineer
>
> CompassLearning, Inc.
> 2400 N. Commerce Pkwy.
> Suite #404
> Weston, FL 33326
>
>
Message #3 by =?iso-8859-1?Q?Oddur_Sn=E6r_Magn=FAsson?= <oddur@n...> on Mon, 10 Jun 2002 15:07:43 -0000
|
|
C#:
If (!reader.Read())
{
Response.Write("it's empty");
}
VB.net:
If not reader.Read() then
Response.Write("it's empty")
End if
-----------------------------------
>
> Oddur Sn=E6r Magn=FAsson
> oddur@d...
> +xxx xxx-xxxx
> http://www.disill.is
>
-----------------------------------
-----Original Message-----
From: Greg Partin [mailto:GPartin@c...]
Sent: m=E1nudagur, j=FAn=ED 10, 2002 14:58
To: aspx_beginners
Subject: [aspx_beginners] finding out if a datareader is empty
how do i find out if a datareader is empty? i can't seem to find a
method or property that would tell me this.
thanks!
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
Message #4 by "Greg Partin" <GPartin@c...> on Mon, 10 Jun 2002 08:11:27 -0700
|
|
That was my first guess..but i'm looking to do this:
if (dr.Read()) then
datagrid.source = dr
datagrid.bind
else
label.text = "There were no records returned"
end if
When i do a read it moves to the 2nd row and the first row is never
printed on my datagrid...any suggestions?
thanks,
Greg
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
>>> ssmith@a... 06/10/02 11:05AM >>>
Use this:
if (dr.Read())
// do stuff
else
// if it was empty
or just
while(dr.Read())
{
// process rows
}
Steve
----- Original Message -----
From: "Greg Partin" <GPartin@c...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Monday, June 10, 2002 10:58 AM
Subject: [aspx_beginners] finding out if a datareader is empty
> how do i find out if a datareader is empty? i can't seem to find a
> method or property that would tell me this.
>
> thanks!
>
> Greg Partin
> Software Engineer
>
> CompassLearning, Inc.
> 2400 N. Commerce Pkwy.
> Suite #404
> Weston, FL 33326
>
>
Message #5 by "Greg Partin" <GPartin@c...> on Mon, 10 Jun 2002 09:17:57 -0700
|
|
For those of you interested, here is how i did it:
dim test as integer
datagrid.source = dr
datagrid.visible = false
datagrid.bind
test = dr.items.count
if test <> 0 then
dr.visible = true
else
label.visible = true
label.text = "There were no records returned"
end if
who would have ever thought they would not have included a isempty()
method on a datareader...as we say around here, .net makes hard things
easy, but easy things hard.
thanks,
greg
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
>>> GPartin@c... 06/10/02 11:11AM >>>
That was my first guess..but i'm looking to do this:
if (dr.Read()) then
datagrid.source = dr
datagrid.bind
else
label.text = "There were no records returned"
end if
When i do a read it moves to the 2nd row and the first row is never
printed on my datagrid...any suggestions?
thanks,
Greg
Greg Partin
Software Engineer
CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL 33326
>>> ssmith@a... 06/10/02 11:05AM >>>
Use this:
if (dr.Read())
// do stuff
else
// if it was empty
or just
while(dr.Read())
{
// process rows
}
Steve
----- Original Message -----
From: "Greg Partin" <GPartin@c...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Monday, June 10, 2002 10:58 AM
Subject: [aspx_beginners] finding out if a datareader is empty
> how do i find out if a datareader is empty? i can't seem to find a
> method or property that would tell me this.
>
> thanks!
>
> Greg Partin
> Software Engineer
>
> CompassLearning, Inc.
> 2400 N. Commerce Pkwy.
> Suite #404
> Weston, FL 33326
>
>
|
|
 |