Object Required Error In Asp
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Function Error Object Required 800a01a8 up vote 1 down vote favorite I'm relatively new to functions and classes so not too sure if this is a beginners mistake. I'm getting: Microsoft VBScript runtime error '800a01a8' Object required: 'EngineerNote(...)' /backup-check/backup_frontendlist_import_NEW.asp, line 76 Line 76 is: Set NoteArray=EngineerNote(company, servername, backupsolution) The three variables I'm passing are all strings. All the function and class is set in: 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 asp-classic vbscript share|improve this question asked Jul 4 '13 at 11:20 Trinitrotoluene 55821126 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote accepted Most likely your database query didn't return any results. You only set the return value of your function when the recordset isn't at EOF: If Recordset.EOF Then 'Do Nothing Else ... Set Engineernote = NoteResults End If Setting the return value to Nothing (or to an empty EngineerNoteClass object) in the Then branch should make the error go away: If Recordset.EOF Then Set EngineerNote = Nothing Else ... Set Engineernote = NoteResults End If Make sure
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBScript Object Required When Trying to set DateTime up vote -1 down vote favorite I am new to VBScript and can't figure out why I'm getting an Object Required error with my http://stackoverflow.com/questions/17468979/function-error-object-required-800a01a8 code. It's very simple right now, I've just begun it: <% set fs=Server.CreateObject("Scripting.FileSystemObject") Dim dateandtime On Error Resume Next set dateandtime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") If Err <> 0 Then ' File operation(s) failed, handle the error response.write(Err.Description) End If %> Why am I not able to set the DateTime? I've set the FileSystemObject for use later in the code FYI. I'm just putting it all in here so you see exactly what I have. I figure it's a simple syntax http://stackoverflow.com/questions/23645754/vbscript-object-required-when-trying-to-set-datetime thing but I can't seem to find the answer anywhere. Thanks for your help! vbscript asp-classic share|improve this question asked May 14 '14 at 4:40 MillerMedia 1,088104190 possible duplicate of "Object required" when using Set in an assignment –Lankymart May 14 '14 at 8:35 1 Same issue use of Set on data types that are not objects (in VBScript). Also use of .Net syntax DateTime.Now.ToString() should be Now() for Classic ASP equivalent or a custom date format. See Answer to Classic ASP - Format current date and time. –Lankymart May 14 '14 at 8:38 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted The first mistake is to use Set when assigning a non-object to a variable. The last entry in the 'Related' list “Object required” when using Set in an assignment deals with it. >> Set dt = "a string" >> Error Number: 424 Error Description: Object required [because Set wants an object to assign] No Set, no problem: >> dt = "a string" >> WScript.Echo dt >> a string Removing the Set will reveal the next problem: Unless you defined a suitable class and an instance named 'DateTime' of your own, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") will fail with the same error 424. >> dt = Nix.Now.ToString("") >> Error Number: 424 Error Description: Object required [to use its .Now member] Do a search here for ways to
error '800a01a8' Page 1 of 1 New Topic/Question Reply 2 Replies - 6364 Views - Last Post: 24 June 2010 - 02:11 PM Rate Topic: http://www.dreamincode.net/forums/topic/178111-classic-asp-object-required-error/ #1 codeladySRQ New D.I.C Head Reputation: 0 Posts: 6 Joined: https://bytes.com/topic/asp-classic/answers/516963-object-required-error-using-filesystemobject 16-June 10 Classic ASP Object Required Error Posted 17 June 2010 - 07:45 AM I am a novice programmer. I have never learned Classic ASP (or any server-side programs). I am trying to open and read a text file and read the IP addresses object required in the file and allow only the IP addresses in the file access to the server and deny all else. Line 42 is: If Contents.InStr(pIP) > 0 Then pIP is in the text file along with the IP addresses. I would rather do this via code than access lists on the router. But I keep getting object required error this error: Microsoft VBScript runtime error '800a01a8' Object required: 'Contents' /Folder/ValidAddressList.asp, line 42 Here is my code: FUNCTION ValidIPs(pIP) Const Filename = "/Folder/ipaddress.txt" ' file of ip addresses to read Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 ' create a filesystem object Dim FSO set FSO = server.CreateObject("Scripting.FileSystemObject") ' map the logical path to the physical system path Dim Filepath Filepath = Server.MapPath(Filename) IF FSO.FileExists(Filepath) Then Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, TristateUseDefault) ' read file in one hit, then close text file Dim Contents ' Dim position ' Position=instr(1, contents, pIP,comparemethod.text) 'if isObject(Contents) then ' set objectName = nothing 'end if ' Set Contents = nothing ' Set Contents.InStr(pIP) = nothing Contents = TextStream.ReadAll If Contents.InStr(pIP) > 0 Then ValidIPs = true Else ValidIPs = false End If TextStream.Close Set TextStream = nothing ELSE ' close file TextStream.Close Set FSO = nothing END IF END FUNCTION %> Is This A Good Question/Topic?
Question Need help? Post your question and get tips & solutions from a community of 418,604 IT Pros & Developers. It's quick & easy. 'object required' error using FileSystemObject P: n/a google I am trying to use the following ASP code to examine the file names in a folder: Dim fso, f, fl, s, fs Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("C:\Inetpub\wwwroot\MySite\subfolder ") Set fs = f.Files For Each fl in fs s = fl.Name 'Object Required error occurs here! Response.Write(s) Next Set fso = Nothing The asp page returns the 'Object Required' error on the line, "s = fl.Name". Why? Can anyone shed any light on this? Thanks Jul 28 '06 #1 Post Reply Share this Question 7 Replies P: n/a Janette For what it is worth, I have run this as both a stand alone vbscript and as an ASP page, and the only thing I changed was the path in the GetFolder command, and it worked fine for both. Both for a folder that did and didn't have contents. My only suggestions, are double check that you have the path correct and check that you have appropriate permissions to the folder. Also it might be worth running this script as a vbscript ie take the code, put it in a file called xxxx.vbs, change response.write(s) to msgbox s, save and run it by double clicking. This may help identify if it is a permissions problem. Hope this helps Janette