WScript.CreateObject not working suddenly

All of a sudden this line is producing an error (we made no changes to code):

Set rs = WScript.CreateObject("ADODB.Recordset")

Open in new window

Microsoft VBScript runtime error '800a01a8'

Object required: 'WScript'

/weather.asp, line 15

The full code is as follows:

   Dim sSQL, rs
	Dim count
	sSQL = "SELECT wea_id, wea_url FROM CLR_Weather "
	Set rs = WScript.CreateObject("ADODB.Recordset")
    rs.Open sSQL, CONNSTR
	if NOT rs.EOF then
		do While not rs.EOF

			call getWeather(rs.Fields("wea_url"),rs.Fields("wea_id"))
	end if
	Set rs = Nothing		

Open in new window

Who is Participating?
Big MontyConnect With a Mentor Senior Web Developer / CEO of Commented:
There was no way that was working before, WScript doesn't have a recordset property to it. It should be

Set rs = Server.CreateObject("ADODB.Recordset")
intoxicated_curveballAuthor Commented:
It was absolutely working before. It's been working for years up until recently. I can even show you other peoples code that are using the same methodology:

Perhaps it's been deprecated ?
intoxicated_curveballAuthor Commented:
Despite what I said, your solution did work, so thank you!
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Can you try to add
Option Explicit

Open in new window

at the beginning of the script and see if this helps.
Big MontySenior Web Developer / CEO of Commented:
@zalazar:  adding "Option Explicit:" will only ensure you have all of your variables declared without any typos. The error the author was getting was related to not being able to initiate a recordset object

@IC: those links were pointing to cases where the code was strictly vbscript, and not classic asp (which I assumed this question was for). if it's just for vbscript, you should be able to get away with

Set rs = CreateObject("ADODB.Recordset")

either way, I'm glad you got it working :)
@Big Monty, thanks, I know. But after reading this thread it seems that it does a little bit more sometimes.
Big MontySenior Web Developer / CEO of Commented:
interesting, I've not come across Option Explicit doing anything but forcing you to declare variables. I wish they had provided some kind of reference for what they were discussing, oh well :)

I did stumble across this article saying that Option Explicit could be used to enhance performance, unfortunately the link they referenced to is broken and I can't find any other info on it.

Either way, thx for pointing that out :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.