Solved

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

Posted on 2006-06-09
17
224 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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