ASP code error, Invalid use of Null.

Associate
Joined
25 Nov 2005
Posts
419
Hi All, getting Invalid use of Null error from the following...

<!-- FileLists.inc - The generation of a file list from a directory -->
<!-- #include file="ShowHits.inc" -->
<%
' Procedure
' FileList of current directory settings
sub FileDirList
if showdebug <> "" then
Response.Write "MyDirectory=" & MyDirectory & "<BR>"
Response.Write "ScriptName=" & ScriptName & "<BR>"
Response.Write "ServerName=" & ServerName & "<BR>"
Response.Write "ServerPath=" & ServerPath & "<BR>"
Response.Write "VPathDir=" & VPathDir & "<BR>"
Response.Write "VPathDirForward=" & VPathDirForward & "<BR>"
end if

if Expanded <> "yes" then
Response.Write "<a href=" & ScriptName & "?Expanded=yes>Expand details</a><br>"
else
Response.Write "<a href=" & ScriptName & "?Expanded=no>Hide details</a><br>"
end if

' Do the current directory
GenDirList("")

dim fso, folder, folders

'create a folder object
set fso=Server.CreateObject("Scripting.FileSystemObject")
set folder=fso.GetFolder(Server.MapPath("."))
set folders=folder.subfolders

' Go through the list of folders
if folders.count>0 then
for each subfolder in folders
GenDirList(subfolder.name)
next
end if
end sub

' Procedure
' GenDirList <DirectoryName>
sub GenDirList (DirectoryName)
on error resume next
dim strQuery

strQuery = "( (#filename *.zip) OR (#filename *.doc) OR (#filename *.xls) OR (#filename *.ppt) OR (#filename *.pdf) OR (#filename *.jpg) OR (#filename *.ai) OR (#filename *.eps) OR (#filename *.gif) ) " &_
"AND (#vpath " & VPathDir & "*) AND ( @write > -720d )"

if UserSearch <> "" then
strQuery = "(" & strQuery & ") AND ( " & UserSearch & " )"
end if

if showdebug <> "" then
Response.Write "DirectoryName=" & DirectoryName & "<BR>"
Response.Write "UserSearch=" & UserSearch & "<BR>"
Response.Write "CompandSearch=" & strQuery & "<BR>"
end if

dim ixQuery ' Index Server query object.
set ixQuery = Server.CreateObject("ixsso.Query")
if (Err.description <> "") Then
Response.Write ("<p><b>Query object Error: " & Err.description & ".</b></p>" & vbCRLF)
Exit sub
end if

ixQuery.Columns = "doctitle, docsubject, docauthor, doccompany, doccomments, vpath, directory, filename, size, write, characterization, rank"
ixQuery.SortBy = "directory, docsubject, filename"
ixQuery.MaxRecords = 200
ixQuery.Query = strQuery
ixQuery.Catalog = "DCG Internal"

' Create a search utility object to allow us to specify the search type as 'deep',
' meaning it will search recursively down through the directories
dim util
set util = Server.CreateObject("ixsso.Util")

if (Err.description <> "") Then
Response.Write ("<p><b>Search Utility Error: " & Err.description & ".</b></p>" & vbCRLF)
Exit sub
end if

util.AddScopeToQuery ixQuery, VPathdirForward & "/" & DirectoryName, "shallow"
' util.AddScopeToQuery ixQuery, VPathdirForward & "/" & DirectoryName, "deep"

' Run the query (i.e. create the recordset).
dim queryRS
set queryRS = ixQuery.CreateRecordSet("nonsequential")

' Check the query result. If it timed out or return no records, then show
' an appropriate message. Otherwise, show the hits.
if (Err.description <> "") Then
Response.Write ("<p><b>Search Recordset Error: " & Err.description & ".</b></p>" & vbCRLF)
Exit sub
Else
if queryRS is Nothing Then
Response.Write ("<p>Query returned no matches.</p>" & vbCRLF)
elseif (ixQuery.QueryTimedOut) then
Response.Write ("<p><b>Error: " & timedOut_Text & ".</b></p>" & vbCRLF)
elseif (queryRS.EOF or queryRS.BOF or queryRS.RecordCount <= 0) then
' Response.Write ("<p>No matches found.</p>" & vbCRLF)
' Empty directory or catalogue hasn't caught up yet
else
' Only print the directory name IF there some matches to show
if ( DirectoryName <> "" ) Then
if ( false ) Then
' If FileList.asp is available in the directory provide a link
Response.Write ("<p><b><a href=" & DirectoryName & "/FileList.asp>"& DirectoryName & "</a></b></p>" & vbCRLF)
else
Response.Write ("<p><b>"& DirectoryName & "</b></p>" & vbCRLF)
end if
end if
call showHits(queryRS, Expanded)
if (Err.number <> 0) Then
Response.Write ("<p><b>Record Display Error: " & Err.description & ".</b></p>" & vbCRLF)
End If
end if
End If

queryRS.close

' Clean up
set queryRS = nothing
set ixQuery = nothing
set util = nothing
end sub

' Generate Audit List
sub AuditList
on error resume next
dim strQuery

if showdebug <> "" then
Response.Write "MyDirectory=" & MyDirectory & "<BR>"
Response.Write "ScriptName=" & ScriptName & "<BR>"
Response.Write "ServerName=" & ServerName & "<BR>"
Response.Write "ServerPath=" & ServerPath & "<BR>"
Response.Write "VPathDir=" & VPathDir & "<BR>"
Response.Write "VPathDirForward=" & VPathDirForward & "<BR>"
end if

strQuery = "( (#filename *.pdf) OR (#filename *.asp) OR (#filename *.htm) OR (#filename *.zip) OR (#filename *.doc) OR (#filename *.xls) OR (#filename *.ppt) ) " &_
"AND (#vpath " & VPathDir & "*) AND ( @write > -720d )"

if UserSearch <> "" then
strQuery = "(" & strQuery & ") AND ( " & UserSearch & " )"
end if

if showdebug <> "" then
Response.Write "UserSearch=" & UserSearch & "<BR>"
Response.Write "CompandSearch=" & strQuery & "<BR>"
end if

dim ixQuery ' Index Server query object.
set ixQuery = Server.CreateObject("ixsso.Query")
if (Err.description <> "") Then
Response.Write ("<p><b>Query object Error: " & Err.description & ".</b></p>" & vbCRLF)
Exit sub
end if

ixQuery.Columns = "doctitle, docsubject, docauthor, doccompany, doccomments, vpath, directory, filename, size, write, characterization, rank"
ixQuery.SortBy = "directory, docsubject, filename"
ixQuery.MaxRecords = 250
ixQuery.Query = strQuery
ixQuery.Catalog = "DCG Internal"

' Create a search utility object to allow us to specify the search type as 'deep',
' meaning it will search recursively down through the directories
dim util
set util = Server.CreateObject("ixsso.Util")

if (Err.description <> "") Then
Response.Write ("<p><b>Search Utility Error: " & Err.description & ".</b></p>" & vbCRLF)
Exit sub
end if

util.AddScopeToQuery ixQuery, VPathDirForward & "/" , "deep"

' Run the query (i.e. create the recordset).
dim queryRS
set queryRS = ixQuery.CreateRecordSet("nonsequential")

' Check the query result. If it timed out or return no records, then show
' an appropriate message. Otherwise, show the hits.
if (Err.description <> "") Then
Response.Write ("<p><b>Search Recordset Error: " & Err.description & ".</b></p>" & vbCRLF)
Exit sub
Else
if queryRS is "" Then
Response.Write ("<p>Query returned no matches.</p>" & vbCRLF)
elseif (ixQuery.QueryTimedOut) then
Response.Write ("<p><b>Error: " & timedOut_Text & ".</b></p>" & vbCRLF)
elseif (queryRS.EOF or queryRS.BOF or queryRS.RecordCount <= 0) then
' Response.Write ("<p>No matches found.</p>" & vbCRLF)
' Empty directory or catalogue hasn't caught up yet
else
call showAuditHits(queryRS)
if (Err.number <> 0) Then
Response.Write ("<p><b>Record Display Error: " & Err.description & ".</b></p>" & vbCRLF)
End If
end if
End If

queryRS.close

' Clean up
set queryRS = nothing
set ixQuery = nothing
set util = nothing
end sub
%>

heeelp
 
You need to build in more "pre-checking" with the FileSystemObject, e.g. only open a file if the folder and file exists.
 
I didn't create the site, I have to move it from an IIS5.0 server to a box running 6.0...... it all works fine except when it lists file i get the error below. No idea where to start!

Thanks!

null.jpg
 
Same result, page is displayed, with Record Display Error: Invalid use of Null. at the bottom of the files displayed. :/
 
The error is displayed when Showhits or ShowAuditHits has failed.

A. You will need to know what line exactly is giving the error. You will need to do some server-side debugging or modify the ASP to give more specific error information.

B. You will need to know what the above two methods do exactly. These are coded in "ShowHits.inc" and are causing your error.
 
Either you debug to find out exactly where/why the error is happening, or you try understand the code in Showhits.inc which might lead you to the cause of the problem. There is no easy fix, you will need to investigate further somehow.
 
I don't have any coding or programming experience unfortunately. Is it easy to run a debug on a particular page?

thanks
 
You will need to enable server-side debugging in IIS on your server and install some kind of ASP debugger. Visual Studio has server components that you can use to debug through VS itself, but you will need to install all this on the server. There are other debugger tools available though.....
 
phill said:
Strange thing is this site works perfectly on the old server with IIS 5. :<

Is Indexing Server running? Have you re-created the same catalogs as on the old server? Are there any files/folders missing? Are the IIS permissions identical on both servers for the virtual web ?
 
Back
Top Bottom