Solved

SQL Query returns error if no matches found (using ASP, MSSQL)

Posted on 1998-10-16
6
120 Views
Last Modified: 2013-12-25
When I run a query that doesn't find any matches it
causes an error on the web page.  Has anyone encountered
this?  
0
Comment
Question by:denam
  • 3
  • 2
6 Comments
 
LVL 1

Author Comment

by:denam
Comment Utility
This is the query:

sGL = "Select LNK.link_id, LNK.link_name from Links LNK, link_sub_index IDX where "
sGL = sGL & " sub_id = " & strID & " and LNK.link_id = IDX.link_id"
Set RSGL = TIADB.Execute(sGL)

This is the error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted; the operation
requested by the application requires a current record.
/private/management/link/remlink.asp, line 49
0
 
LVL 10

Expert Comment

by:MasseyM
Comment Utility
YOu can add this to the top of your ASP page..

<% On Error Resume Next %>

but that is not good to use for begugging :)
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
<%
If Not RSGL.EOF Then
  ..do you things
End If
%>
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:denam
Comment Utility
Sybe, this is pretty much what I have already.  I worded it a little differently:

<%
    while RSQuery.eof = False
         ..do things
    RSQuery.movenext
    wend
%>

Are you supposed to get an error when a query finds no matches?  I assume it's either
that or a problem in the script.
0
 
LVL 28

Accepted Solution

by:
sybe earned 50 total points
Comment Utility
Try this:

<%
Do While Not RSQuery.EOF
  ..do things
  RSQuery.movenext
Loop
%>


0
 
LVL 1

Author Comment

by:denam
Comment Utility
isn't this just a hack?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to dynamically set the form action using jQuery.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now