wharris26
asked on
How to make a custom error when no record is found on an aspvbscript page using dreamweaver.
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.
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
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
I not rsData.EOF Then
Run your scripts...
Else
Response.write("Sorry, there are no records to view")
End If
Hope this helps.
Aplimedia
ASKER
So is this what it should look like?
Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColP aram, "'", "''") + ""
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.
Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColP
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The error might be because of somthing else you are doing on th epage... What is the eror?
Aplimedia
Aplimedia
ASKER
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.ActiveConnectio n = MM_OTPT_STRING
Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColP aram, "'", "''") + ""
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__MMColP aram2, "'", "''") + ""
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?
Set Recordset1 = Server.CreateObject("ADODB
Recordset1.ActiveConnectio
Recordset1.Source = "SELECT * FROM otpt.SIOT WHERE SID = " + Replace(Recordset1__MMColP
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__MMColP
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?
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
Copy and paste it here
Aplimedia
...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
...
ASKER
NO RECORDS FOUND error '80020009'
/ese/otpt/OTPTDynamic/Sear chResultsO T.asp, line 40
/ese/otpt/OTPTDynamic/Sear
ASKER
Line 40 is as follows:
Dim Recordset2__MMColParam2
Recordset2__MMColParam2 = "1"
If (Recordset1("SchoolID") <> "") Then
Recordset2__MMColParam2 = Recordset1("SchoolID")
End If
Dim Recordset2__MMColParam2
Recordset2__MMColParam2 = "1"
If (Recordset1("SchoolID") <> "") Then
Recordset2__MMColParam2 = Recordset1("SchoolID")
End If
Change the line...
IF not Recordset2.EOF THEN
to
IF not Recordset2.EOF THEN And Not Recordset2.BOF then
Let me know..
Aplimedia
ASKER
New Error:
Microsoft VBScript compilation error '800a0400'
Expected statement
/ese/otpt/OTPTDynamic/Sear
IF not Recordset2.EOF THEN AND NOT Recordset2.BOF Then
--------------------------
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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Back to original error.
ASKER
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.
ASKER
I added Response.End() under the Response Write and that stopped the code to keep the error from occuring.
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.