Solved

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

Posted on 2006-06-09
17
222 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple PHP Upload Script 11 2,709
Spry missing in DWcc 6 308
Saving Form Data when Leaving Page 3 356
Adobe Muse CC instead of Adobe Dreamweaver CC? 8 63
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 …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

17 Experts available now in Live!

Get 1:1 Help Now