Solved

How to make a custom error when no record is found on an aspvbscript page using dreamweaver.

Posted on 2006-06-09
17
221 Views
Last Modified: 2010-05-18
I need to make a custom error message for the following error using dreamweaver on an aspvbscript page.
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
0
Comment
Question by:wharris26
  • 8
  • 8
17 Comments
 
LVL 23

Expert Comment

by:adilkhan
Comment Utility
trick is simple


if NOT RS.EOF then

 ' Process your code here

End if

in above example i assume RS is the recordset object.

above line also means if we have "some" records then do something within if statement, otherwise dont return anything from database.

0
 
LVL 10

Expert Comment

by:aplimedia
Comment Utility
The custom error message is  as follows...

I not rsData.EOF Then

Run your scripts...

Else

Response.write("Sorry, there are no records to view")

End If

Hope this helps.

Aplimedia
0
 

Author Comment

by:wharris26
Comment Utility
So is this what it should look like?
Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
IF NOT Recordset1.EOF THEN
Recordset1_numRows = 0
ELSE
RESPONSE.Write("No Records were found")
END IF
IF so I have 2 problems, 1 the browser gives internet friendly error messages not the script I wrote and I still get an error because I have a second recordset that is dependent of the value from the first recordset.  How do I deal with that.
0
 
LVL 10

Accepted Solution

by:
aplimedia earned 500 total points
Comment Utility


Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
IF NOT Recordset1.EOF THEN
Recordset1_numRows = 0
'Enter you 2nd record set here. It will only run if there are records in the first...

Recordset2.Source = "SELECT * FROM bla bla bla...
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
IF NOT Recordset2.EOF THEN
yourString = Recordset2("yout firld")
End IF
ELSE
RESPONSE.Write("No Records were found")
END IF

0
 
LVL 10

Expert Comment

by:aplimedia
Comment Utility
The error might be because of somthing else you are doing on th epage... What is the eror?

Aplimedia
0
 

Author Comment

by:wharris26
Comment Utility
I think the problem is definitely the second recordset.  I did what you said, it looks like this:

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_OTPT_STRING
Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
IF NOT Recordset1.EOF THEN
Recordset1_numRows = 0

Recordset2.Source = "SELECT *  FROM dbo.SchoolLookup  WHERE SchoolID = " + Replace(Recordset2__MMColParam2, "'", "''") + ""
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
IF not Recordset1.EOF THEN
Recordset2_MMColParam2 = Recordset1("SchoolID")
ELSE
END IF
ELSE
RESPONSE.WRITE("NO RECORDS FOUND")
END IF

The error still occurs when Recordset2 variables are defined later in the page:  Looks like this
Dim Recordset2__MMColParam2
Recordset2__MMColParam2 = "1"
If (Recordset1("SchoolID") <> "") Then
  Recordset2__MMColParam2 = Recordset1("SchoolID")

 End If
Can I just address the problem here?
0
 
LVL 10

Expert Comment

by:aplimedia
Comment Utility
If you don't tell me the error you are getting, i will not be able to help you...

Copy and paste it here

Aplimedia
0
 
LVL 10

Expert Comment

by:aplimedia
Comment Utility


...Recordset2.LockType = 1
Recordset2.Open()
IF not Recordset1.EOF THEN <<<<<<<<<<<<<<<<  This should be.. IF not Recordset2.EOF THEN
Recordset2_MMColParam2 = Recordset1("SchoolID")
ELSE
END IF
...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:wharris26
Comment Utility
NO RECORDS FOUND error '80020009'
/ese/otpt/OTPTDynamic/SearchResultsOT.asp, line 40
0
 

Author Comment

by:wharris26
Comment Utility
Line 40 is as follows:
Dim Recordset2__MMColParam2
Recordset2__MMColParam2 = "1"
If (Recordset1("SchoolID") <> "") Then
  Recordset2__MMColParam2 = Recordset1("SchoolID")
 End If
0
 
LVL 10

Expert Comment

by:aplimedia
Comment Utility

Change the line...

IF not Recordset2.EOF THEN

to

IF not Recordset2.EOF THEN And Not Recordset2.BOF then


Let me know..

Aplimedia
0
 

Author Comment

by:wharris26
Comment Utility

New Error:
Microsoft VBScript compilation error '800a0400'

Expected statement

/ese/otpt/OTPTDynamic/SearchResultsOT.asp, line 29

IF not Recordset2.EOF THEN AND NOT Recordset2.BOF Then
---------------------------^
0
 
LVL 10

Expert Comment

by:aplimedia
Comment Utility
Ok...

One too many then's... cahneg line.

IF not Recordset2.EOF THEN AND NOT Recordset2.BOF Then

to

IF not Recordset2.EOF AND NOT Recordset2.BOF Then


Aplimedia
0
 
LVL 10

Assisted Solution

by:aplimedia
aplimedia earned 500 total points
Comment Utility
With all due respect... your question about the error message is digressing into much else... all for 200 points...

0
 

Author Comment

by:wharris26
Comment Utility
Back to original error.
0
 

Author Comment

by:wharris26
Comment Utility
Thank you for your help.  I have increased it to 500 points, however it remains the same question and I do not believe it has digressed.   I still need an custom error message for when no records are returned.  It is only complicated by having a second dependent recordset.  I thought it would be much easier to answer.
0
 

Author Comment

by:wharris26
Comment Utility
I added Response.End() under the Response Write and that stopped the code to keep the error from occuring.
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

Suggested Solutions

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

11 Experts available now in Live!

Get 1:1 Help Now