|
-
Nov 27th, 2003, 02:26 AM
#1
Thread Starter
Lively Member
The Page Cannot Be Found
Hi,
I have a project where I read from a SQL database fields for a qualification. One of the fields is "document path". If this field is not null, i then try and retrieve the actual document. If the document path is null, i just display the fields in typical asp fashion.
My problem is that sometimes the document path field has data, but the physical document actually isnt there, and so, the browser displays a url that does not exist and I get the "Page cannot be displayed".
I need to be able to have code that says...if the document isnt there, then treat it the same way it handles the scenario when the document path is null.
Code:
if len(trim(rslist("DocumentPath"))) > 0 then
url="../../US/Documents/" & rslist("DocumentPath")
Response.Redirect(url)
else
display all fields...
%>
any advice is welcome..
thankls in advance
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
-
Nov 27th, 2003, 03:43 AM
#2
You should check to see if the file exists before displaying it.
VB Code:
Dim FileName
FileName = "MyFile.asp"
FileName = Server.MapPath("/Files/" & FileName)
If IsFileExists(FileName) = True Then
Response.Write "File exists"
Else
Response.Write "File does not exists"
End If
' **********************************
' Function to check file Existance
' **********************************
Function IsFileExists(byVal FileName)
If FileName = "" Then
IsFileExists = False
Exit Function
End If
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists( FileName ) = True Then
IsFileExists = True
Else
IsFileExists = False
End If
Set objFSO = Nothing
End Function
(Sample code, modify it!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|