Need help making a connection

Author Message
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)
0
[Helpful answer received] / [List Solutions Only]
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.
 
#1
    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)
    0
    So you are running this as a stand alone VBScript?
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      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)
      0
      Yes, under cscript.
       
      #3
        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)
        0
        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.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          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)
          0
          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
           
          #5
            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)
            5
            [This post was marked as helpful]
            If running on 64bit...you might try and navigate to the 32 bit version of cscript and launch your script using that.
            dm_4ever

            My philosophy: K.I.S.S - Keep It Simple Stupid
            Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
            Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
             
            #6
              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)
              0
              I've only got one instance of cscript.exe, in C:\Windows\System32.
               
               
              #7
                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)
                0
                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?
                dm_4ever

                My philosophy: K.I.S.S - Keep It Simple Stupid
                Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
                Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
                 
                #8
                  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)
                  0
                  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!
                   
                  #9

                    Online Bookmarks Sharing: Share/Bookmark

                    Jump to:

                    Current active users

                    There are 0 members and 1 guests.

                    Icon Legend and Permission

                    • New Messages
                    • No New Messages
                    • Hot Topic w/ New Messages
                    • Hot Topic w/o New Messages
                    • Locked w/ New Messages
                    • Locked w/o New Messages
                    • Read Message
                    • Post New Thread
                    • Reply to message
                    • Post New Poll
                    • Submit Vote
                    • Post reward post
                    • Delete my own posts
                    • Delete my own threads
                    • Rate post

                    2000-2012 ASPPlayground.NET Forum Version 3.9