簡體   English   中英

功能錯誤對象必需800a01a8

[英]Function Error Object Required 800a01a8

我對函數和類比較陌生,所以不太確定這是否是初學者的錯誤。 我越來越:

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

您的數據庫查詢很可能沒有返回任何結果。 僅當記錄集不在EOF時才設置函數的返回值:

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

Then分支中將返回值設置為Nothing (或為空的EngineerNoteClass對象)應使錯誤消失:

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

確保在其余腳本中適當地處理了返回的值/對象。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM