Clothahump
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 1/23/2012
-
Status: offline
|
Need help making a connection
Monday, January 23, 2012 7:19 AM
( permalink)
I'm an old VB6er moving into the world of cscript and vbscript. I've copied and pasted code from websites that say this is how to open a recordset, etc., but my issue is that I get an error 424 (Object Required) right up front on the line that creates the connection and everything tanks from that point onward. Set SQLcon = CreateObject("ADODB.Connection")
if err.number <> 0 then
sline = "Error " & err.number & " creating connection" & vbcrlf & err.Description
wscript.echo sline
logfile.write (sline)
end if
set rs=Createobject ("ADODB.Recordset")
if err.number <> 0 then
sline = "Error " & err.number & " creating recordset" & vbcrlf & err.Description
wscript.echo sline
logfile.write (sline)
end if
SQLcon.Open "dsn=Flatcurrent"
rs.CursorLocation = adUseClient
rs.open "select top 1 * from tblProgress",adopenstatic,adlockoptimitic
if err.number <> 0 then
sline = "Error " & err.number & " opening recordset" & vbcrlf & err.Description
wscript.echo sline
logfile.write (sline)
end if
All variables are declared at the beginning of the module. What's causing this? Is it unable to resolve ADODB.Connection? MDAC version is 2.8, running on WinServer 2003, SP2.
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:Need help making a connection
Monday, January 23, 2012 7:31 AM
( permalink)
So you are running this as a stand alone VBScript?
|
|
|
|
Clothahump
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 1/23/2012
-
Status: offline
|
Re:Need help making a connection
Monday, January 23, 2012 8:43 AM
( permalink)
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:Need help making a connection
Monday, January 23, 2012 8:55 AM
( permalink)
you can check Classes Root in the registry for a definition of ADODB.Connection. Other than that I can't think of a reason why it wouldn't be able to instantiate the object.
|
|
|
|
Clothahump
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 1/23/2012
-
Status: offline
|
Re:Need help making a connection
Wednesday, January 25, 2012 2:02 AM
( permalink)
ebgreen you can check Classes Root in the registry for a definition of ADODB.Connection. Other than that I can't think of a reason why it wouldn't be able to instantiate the object. It's there. Shows CurVer = ADODB.Connection.2.8
|
|
|
|
dm_4ever
-
Total Posts
:
3687
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
Re:Need help making a connection
Wednesday, January 25, 2012 2:57 AM
( permalink)
If running on 64bit...you might try and navigate to the 32 bit version of cscript and launch your script using that.
|
|
|
|
Clothahump
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 1/23/2012
-
Status: offline
|
Re:Need help making a connection
Wednesday, January 25, 2012 3:09 AM
( permalink)
I've only got one instance of cscript.exe, in C:\Windows\System32.
|
|
|
|
dm_4ever
-
Total Posts
:
3687
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
Re:Need help making a connection
Wednesday, January 25, 2012 3:36 AM
( permalink)
I just checked because I remember having a problem recently using ADODB on my machine and launching the script using Windows\SysWOW64\cscript.exe was what I needed. Maybe try reinstalling MDAC?
|
|
|
|
Clothahump
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 1/23/2012
-
Status: offline
|
Re:Need help making a connection
Wednesday, January 25, 2012 7:59 AM
( permalink)
dm_4ever If running on 64bit...you might try and navigate to the 32 bit version of cscript and launch your script using that. Okay, you got me thinking. SysWOW64 isn't on this machine, so I copied a 32 bit version of cscript from another machine and ran using it. That was the solution - no more errors. Thanks!
|
|
|
|