Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > EOF .NET equivalent?

Reply
Thread Tools

EOF .NET equivalent?

 
 
D. Shane Fowlkes
Guest
Posts: n/a
 
      12-03-2003
When using classic ASP, I would use something like what's below to show HTML
if the recordset was empty.

<% If RS.EOF And RS.BOF Then %>
<p>There are no records to display.</p>
<% End If %>

Now...as I'm learning ASP.NET, I'll use something like what's below to loop
thru a recordset.

<%
While MyData.Read()
Response.Write...stuff.....
End While
%>

But as simple as it may seem, I cannot find any references in my books or
online how to "detect" if the recordset is empty. I'm basing my SELECT
statement off of a search form so if the user types something that's not
useful like "tuvwxyz", the query will most likely return nothing. Any
pointers?

Thanks

--



*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************



 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      12-03-2003
Shane,

If there are no records While MyData.Read will never begin the loop.

It's just skipped over automatically because .Read never fires since there
are no records.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


"D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
news:OF%(E-Mail Removed)...
> When using classic ASP, I would use something like what's below to show

HTML
> if the recordset was empty.
>
> <% If RS.EOF And RS.BOF Then %>
> <p>There are no records to display.</p>
> <% End If %>
>
> Now...as I'm learning ASP.NET, I'll use something like what's below to

loop
> thru a recordset.
>
> <%
> While MyData.Read()
> Response.Write...stuff.....
> End While
> %>
>
> But as simple as it may seem, I cannot find any references in my books or
> online how to "detect" if the recordset is empty. I'm basing my SELECT
> statement off of a search form so if the user types something that's not
> useful like "tuvwxyz", the query will most likely return nothing. Any
> pointers?
>
> Thanks
>
> --
>
>
>
> *********************************
> D. Shane Fowlkes - TMM
> Saving the world, one web site at a time.
> http://www.shanefowlkes.com
> *********************************
>
>
>



 
Reply With Quote
 
 
 
 
D. Shane Fowlkes
Guest
Posts: n/a
 
      12-03-2003
Yes, I know. That's my point. How would I display a message indicating
there are no records when there are no records? For example...

<% If Not RS.EOF Or Not RS.BOF Then %>
Go thru my loop and display records.......
<% Else %>
<p> Sorry, there are no matching your request at this time. </p>
<% End If%>

Thanks

--


*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************


"S. Justin Gengo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Shane,
>
> If there are no records While MyData.Read will never begin the loop.
>
> It's just skipped over automatically because .Read never fires since there
> are no records.
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
> news:OF%(E-Mail Removed)...
> > When using classic ASP, I would use something like what's below to show

> HTML
> > if the recordset was empty.
> >
> > <% If RS.EOF And RS.BOF Then %>
> > <p>There are no records to display.</p>
> > <% End If %>
> >
> > Now...as I'm learning ASP.NET, I'll use something like what's below to

> loop
> > thru a recordset.
> >
> > <%
> > While MyData.Read()
> > Response.Write...stuff.....
> > End While
> > %>
> >
> > But as simple as it may seem, I cannot find any references in my books

or
> > online how to "detect" if the recordset is empty. I'm basing my SELECT
> > statement off of a search form so if the user types something that's not
> > useful like "tuvwxyz", the query will most likely return nothing. Any
> > pointers?
> >
> > Thanks
> >
> > --
> >
> >
> >
> > *********************************
> > D. Shane Fowlkes - TMM
> > Saving the world, one web site at a time.
> > http://www.shanefowlkes.com
> > *********************************
> >
> >
> >

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      12-03-2003
if objDR.Read() then
Do
...
Loop While objDR.Read()
Else
...
End If

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes, I know. That's my point. How would I display a message indicating
> there are no records when there are no records? For example...
>
> <% If Not RS.EOF Or Not RS.BOF Then %>
> Go thru my loop and display records.......
> <% Else %>
> <p> Sorry, there are no matching your request at this time. </p>
> <% End If%>
>
> Thanks
>
> --
>
>
> *********************************
> D. Shane Fowlkes - TMM
> Saving the world, one web site at a time.
> http://www.shanefowlkes.com
> *********************************
>
>
> "S. Justin Gengo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Shane,
> >
> > If there are no records While MyData.Read will never begin the loop.
> >
> > It's just skipped over automatically because .Read never fires since

there
> > are no records.
> >
> > --
> > Sincerely,
> >
> > S. Justin Gengo, MCP
> > Web Developer / Programmer
> >
> > Free code library at:
> > www.aboutfortunate.com
> >
> > "Out of chaos comes order."
> > Nietzche
> >
> >
> > "D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
> > news:OF%(E-Mail Removed)...
> > > When using classic ASP, I would use something like what's below to

show
> > HTML
> > > if the recordset was empty.
> > >
> > > <% If RS.EOF And RS.BOF Then %>
> > > <p>There are no records to display.</p>
> > > <% End If %>
> > >
> > > Now...as I'm learning ASP.NET, I'll use something like what's below to

> > loop
> > > thru a recordset.
> > >
> > > <%
> > > While MyData.Read()
> > > Response.Write...stuff.....
> > > End While
> > > %>
> > >
> > > But as simple as it may seem, I cannot find any references in my books

> or
> > > online how to "detect" if the recordset is empty. I'm basing my

SELECT
> > > statement off of a search form so if the user types something that's

not
> > > useful like "tuvwxyz", the query will most likely return nothing. Any
> > > pointers?
> > >
> > > Thanks
> > >
> > > --
> > >
> > >
> > >
> > > *********************************
> > > D. Shane Fowlkes - TMM
> > > Saving the world, one web site at a time.
> > > http://www.shanefowlkes.com
> > > *********************************
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12-03-2003
There are a couple of ways. Using your methodology, you can do the
following:

<%
Dim blnRecords As Boolean = false

While MyData.Read()
'Set boolean
blnRecords = true
Response.Write...stuff.....
End While

If blnRecords = False then
Response.Write("No records dood!")
End If
%>

In general, I would learn to write from codeBehind, rather than embed code.
While it was necessary in ASP, it is bad form, overall, in ASP.NET (changes
a bit in ASP.NET 2.0 - Whidbey, but that is another story).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes, I know. That's my point. How would I display a message indicating
> there are no records when there are no records? For example...
>
> <% If Not RS.EOF Or Not RS.BOF Then %>
> Go thru my loop and display records.......
> <% Else %>
> <p> Sorry, there are no matching your request at this time. </p>
> <% End If%>
>
> Thanks
>
> --
>
>
> *********************************
> D. Shane Fowlkes - TMM
> Saving the world, one web site at a time.
> http://www.shanefowlkes.com
> *********************************
>
>
> "S. Justin Gengo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Shane,
> >
> > If there are no records While MyData.Read will never begin the loop.
> >
> > It's just skipped over automatically because .Read never fires since

there
> > are no records.
> >
> > --
> > Sincerely,
> >
> > S. Justin Gengo, MCP
> > Web Developer / Programmer
> >
> > Free code library at:
> > www.aboutfortunate.com
> >
> > "Out of chaos comes order."
> > Nietzche
> >
> >
> > "D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
> > news:OF%(E-Mail Removed)...
> > > When using classic ASP, I would use something like what's below to

show
> > HTML
> > > if the recordset was empty.
> > >
> > > <% If RS.EOF And RS.BOF Then %>
> > > <p>There are no records to display.</p>
> > > <% End If %>
> > >
> > > Now...as I'm learning ASP.NET, I'll use something like what's below to

> > loop
> > > thru a recordset.
> > >
> > > <%
> > > While MyData.Read()
> > > Response.Write...stuff.....
> > > End While
> > > %>
> > >
> > > But as simple as it may seem, I cannot find any references in my books

> or
> > > online how to "detect" if the recordset is empty. I'm basing my

SELECT
> > > statement off of a search form so if the user types something that's

not
> > > useful like "tuvwxyz", the query will most likely return nothing. Any
> > > pointers?
> > >
> > > Thanks
> > >
> > > --
> > >
> > >
> > >
> > > *********************************
> > > D. Shane Fowlkes - TMM
> > > Saving the world, one web site at a time.
> > > http://www.shanefowlkes.com
> > > *********************************
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12-03-2003
See answer farther down the thread!

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"D. Shane Fowlkes" <(E-Mail Removed)> wrote in message
news:OF%(E-Mail Removed)...
> When using classic ASP, I would use something like what's below to show

HTML
> if the recordset was empty.
>
> <% If RS.EOF And RS.BOF Then %>
> <p>There are no records to display.</p>
> <% End If %>
>
> Now...as I'm learning ASP.NET, I'll use something like what's below to

loop
> thru a recordset.
>
> <%
> While MyData.Read()
> Response.Write...stuff.....
> End While
> %>
>
> But as simple as it may seem, I cannot find any references in my books or
> online how to "detect" if the recordset is empty. I'm basing my SELECT
> statement off of a search form so if the user types something that's not
> useful like "tuvwxyz", the query will most likely return nothing. Any
> pointers?
>
> Thanks
>
> --
>
>
>
> *********************************
> D. Shane Fowlkes - TMM
> Saving the world, one web site at a time.
> http://www.shanefowlkes.com
> *********************************
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse Java 67 03-14-2012 12:21 AM
ifstream eof not reporting eof? SpreadTooThin C++ 10 06-15-2007 08:49 AM
if EOF = -1, can't a valid character == EOF and cause problems? Kobu C Programming 10 03-04-2005 10:40 PM
A question about EOF SL_McManus Perl 1 12-04-2003 01:50 AM
How to check for EOF (End of file) when using StreamReader to parse text file Sacha Korell ASP .Net 2 09-06-2003 02:59 PM



Advertisments