• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

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"))
			rs.movenext
		loop
	end if
	
	rs.Close()
	Set rs = Nothing		

Open in new window

0
intoxicated_curveball
Asked:
intoxicated_curveball
  • 3
  • 2
  • 2
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org 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")
0
 
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:

https://community.oracle.com/thread/2603156?start=0&tstart=0
http://computer-programming-forum.com/59-vbscript/bcd1c59d5b5b2e64.htm
http://stackoverflow.com/questions/19594056/vbscript-function-variable-not-resolving

Perhaps it's been deprecated ?
0
 
intoxicated_curveballAuthor Commented:
Despite what I said, your solution did work, so thank you!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
zalazarCommented:
Can you try to add
Option Explicit

Open in new window

at the beginning of the script and see if this helps.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org 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 :)
0
 
zalazarCommented:
@Big Monty, thanks, I know. But after reading this thread it seems that it does a little bit more sometimes.
http://www.experts-exchange.com/Programming/Languages/Scripting/ASP/Q_21869129.html
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org 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 :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now