mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 MySQL connections

Author Message
Kravis

  • Total Posts : 13
  • Scores: 0
  • Reward points : 0
  • Joined: 3/9/2010
  • Status: offline
MySQL connections Tuesday, March 09, 2010 8:52 AM (permalink)
0
I've got some batch-file based logon scripts that I'm trying to migrate to VBScript for next year (I work at a school and plan a year in advance). The way the batch files work now is they search a series of text config files to find campus, room, and workstation-specific configurations such as printer assignments and software installations. This is handy when you have to support 1,500 computers and don't want to configure them by hand ever time they get replaced or imaged.
 
As part of the move to VBScript, I'd like to drop the limitations of text files and move to reading configurations from a MySQL server I just got set up. The problem is, I can't find good information on doing this with client-side VBS. I've found quite a bit of ASP code and a few VBS scripts that use DSNs (not an option as I don't want to set up a DSN on 1,500 student-accessible computers), but I've had a hard time locating good information on how to do it using WSH. Searches on these forums keep pointing me to connectionstring.com, which looks to have let its domain lapse.
 
So for starters, I need help getting the connection working and running a simple SELECT query.
#1
    Kravis

    • Total Posts : 13
    • Scores: 0
    • Reward points : 0
    • Joined: 3/9/2010
    • Status: offline
    Re:MySQL connections Tuesday, March 09, 2010 8:56 AM (permalink)
    0
    ...and now connectionstrings.com works. It seems there was a DNS hiccup on our network this morning.
    #2
      Deckyon

      • Total Posts : 45
      • Scores: 0
      • Reward points : 0
      • Joined: 8/1/2006
      • Location: Louisville, KY - USA
      • Status: offline
      Re:MySQL connections Tuesday, March 09, 2010 9:06 AM (permalink)
      0
      Well that was easy.  Mark this trouble call closed.
      #3
        Kravis

        • Total Posts : 13
        • Scores: 0
        • Reward points : 0
        • Joined: 3/9/2010
        • Status: offline
        Re:MySQL connections Tuesday, March 09, 2010 9:26 AM (permalink)
        0
        Not so fast, I'm still a bit of a noob :)

        Here's my code so far:

        SQLserver = "CISD2K3-SS2" 
             SQLdb = "test" 
             SQLquery = "SELECT * FROM test" Set Connection = CreateObject("ADODB.Connection") 
             Set Recordset = CreateObject("ADODB.Recordset") ConnString =  "Driver={MySQL ODBC 3.51 Driver};Server=CISD2K3-SS2;Database=test;User=QueryUser;Password=password;Option=3;" Connection.Open ConnString Recordset.Open SQLquery,Connection If Recordset.EOF Then 
             WScript.Quit() 
             Else 
             Do While NOT Recordset.Eof 
             wscript.echo Recordset("column1") 
             wscript.echo Recordset("column2") 
             Recordset.MoveNext Loop 
             End If Recordset.Close 
             Set Recordset=nothing 
             Connection.Close 
             Set Connection=nothing

        (yes I know I don't use all of those variables in the current code. I'll be putting them into the code once I get it working)
        And here's the error I get when I run it:

        Script: c:\test2.vbs
        Line: 10
        Char: 1
        Error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
        Code: 80004005
        Source: Microsoft OLE DB Provider for ODBC Drivers
        <message edited by Kravis on Tuesday, March 09, 2010 9:27 AM>
        #4
          dm_4ever

          • Total Posts : 3673
          • Scores: 82
          • Reward points : 0
          • Joined: 6/29/2006
          • Location: Orange County, California
          • Status: offline
          Re:MySQL connections Tuesday, March 09, 2010 9:46 AM (permalink)
          0
          Have you installed the drivers?
          http://dev.mysql.com/downloads/connector/odbc/
          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
          #5
            Kravis

            • Total Posts : 13
            • Scores: 0
            • Reward points : 0
            • Joined: 3/9/2010
            • Status: offline
            Re:MySQL connections Tuesday, March 09, 2010 9:55 AM (permalink)
            0
            Yes, I downloaded and installed the driver yesterday.
            #6
              dm_4ever

              • Total Posts : 3673
              • Scores: 82
              • Reward points : 0
              • Joined: 6/29/2006
              • Location: Orange County, California
              • Status: offline
              Re:MySQL connections Tuesday, March 09, 2010 10:00 AM (permalink)
              0
              If you have the newest driver 5.1 then you should try the corresponding connection string.
              http://www.connectionstrings.com/mysql#p31
              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
              #7
                Kravis

                • Total Posts : 13
                • Scores: 0
                • Reward points : 0
                • Joined: 3/9/2010
                • Status: offline
                Re:MySQL connections Wednesday, March 10, 2010 9:20 AM (permalink)
                0
                Umm...I did. It's in the code I posted above.
                #8
                  ehvbs

                  • Total Posts : 3312
                  • Scores: 110
                  • Reward points : 0
                  • Joined: 6/22/2005
                  • Location: Germany
                  • Status: offline
                  Re:MySQL connections Wednesday, March 10, 2010 9:50 AM (permalink)
                  0
                  ConnString =  "Driver={MySQL ODBC 3.51 Driver}
                  vs.
                  Driver={MySQL ODBC 5.1 Driver}
                  #9
                    Kravis

                    • Total Posts : 13
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 3/9/2010
                    • Status: offline
                    Re:MySQL connections Thursday, March 11, 2010 2:42 AM (permalink)
                    0
                    Ah! That was it. Even after I'd gone through and looked at the driver information in XP it didn't register, probably becauase 3.51 and 5.1 are close enough to "look right" at a glance. Why they couldn't just stick with "MySQL ODBC Driver"...sigh.

                    Thanks, my basic queries are working now. Now on to figuring out just how to actually execute my plans :)
                    #10

                      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.8
                      mbt shoes www.wileywilson.com