Solved

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

Posted on 2006-06-09
17
225 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:Saqib Khan
ID: 16875634
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
ID: 16880454
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
ID: 16886479
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 10

Accepted Solution

by:
aplimedia earned 500 total points
ID: 16886659


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
ID: 16886668
The error might be because of somthing else you are doing on th epage... What is the eror?

Aplimedia
0
 

Author Comment

by:wharris26
ID: 16887391
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
ID: 16887512
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
ID: 16887527


...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
 

Author Comment

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

Author Comment

by:wharris26
ID: 16887625
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
ID: 16887708

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
ID: 16887773

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
ID: 16887811
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
ID: 16887821
With all due respect... your question about the error message is digressing into much else... all for 200 points...

0
 

Author Comment

by:wharris26
ID: 16887838
Back to original error.
0
 

Author Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
adobe product that creates checks to sales people for bringing sales 5 391
CSS HTML Text Alignment 13 427
CSS Layout Help 7 234
Adobe Photoshop CC 2015 action script help 2 225
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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