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.
|
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)
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.
|
|
|
|
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)
...and now connectionstrings.com works. It seems there was a DNS hiccup on our network this morning.
|
|
|
|
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)
Well that was easy. Mark this trouble call closed.
|
|
|
|
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)
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>
|
|
|
|
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)
|
|
|
|
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)
Yes, I downloaded and installed the driver yesterday.
|
|
|
|
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)
|
|
|
|
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)
Umm...I did. It's in the code I posted above.
|
|
|
|
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)
ConnString = "Driver={MySQL ODBC 3.51 Driver} vs. Driver={MySQL ODBC 5.1 Driver}
|
|
|
|
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)
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 :)
|
|
|
|
Online Bookmarks Sharing: