2

我对函数和类比较陌生,所以不太确定这是否是初学者的错误。我越来越:

Microsoft VBScript runtime error '800a01a8' 

Object required: 'EngineerNote(...)' 

/backup-check/backup_frontendlist_import_NEW.asp, line 76 

第 76 行是:

Set NoteArray=EngineerNote(company, servername, backupsolution)

我传递的三个变量都是字符串。所有函数和类都设置在:

Class EngineerNoteClass
public note
public notesubmitdate
End Class

Function EngineerNote(Company, ServerName, Solution)
Set RecordSet = Server.CreateObject("ADODB.Recordset")
RecordSetSQLString = "SELECT note, submitdate FROM tbl_BackupChecks_AuditInformation WHERE Company='" & company & "' AND ServerName='" & servername & "' AND Solution='" & solution & "' ORDER BY submitdate desc;"
RecordSet.Open RecordSetSQLString, DatabaseConnection
If Recordset.EOF Then
'Do Nothing
Else
Dim NoteResults
Set NoteResults = new EngineerNoteClass
noteresults.note = RecordSet("note")
noteresults.notesubmitdate = RecordSet("submitdate")
Set Engineernote = NoteResults
End If
Recordset.Close
End Function
4

1 回答 1

5

您的数据库查询很可能没有返回任何结果。仅当记录集不在时才设置函数的返回值EOF

If Recordset.EOF Then
  'Do Nothing
Else
  ...
  Set Engineernote = NoteResults
End If

在分支中将返回值设置为Nothing(或空EngineerNoteClass对象)Then应该会使错误消失:

If Recordset.EOF Then
  Set EngineerNote = Nothing
Else
  ...
  Set Engineernote = NoteResults
End If

确保在脚本的其余部分中适当地处理返回的值/对象。

于 2013-07-04T13:01:10.653 回答