Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB SCRIPT connect to remote mySQL database

Posted on 2009-05-19
5
Medium Priority
?
782 Views
Last Modified: 2012-05-07
Okay, I have the attached code which connects to a MSSQL server.  What I want, if possible, is the most similar code I can that will connect to a mySQL server.  I would like the syntax to be as similar as possible.
Dim cConnection
Set cConnection = CreateObject("ADODB.Connection")
DBConString = "Provider=SQLOLEDB.1;Data Source=servername;Initial Catalog=Portal_Test"	
cConnection.Open DBConString,"username","password"
SQLstmt = "SELECT ServerName, Notes from ServerData"
Set RS = cConnection.Execute(SQLstmt)	
Do While (not RS.EOF) and (intCount < 5)
	'msgbox RS.Fields("ServerName").value
	intCount = intCount + 1
	RS.movenext
Loop

Open in new window

0
Comment
Question by:Cerixus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 1

Author Comment

by:Cerixus
ID: 24426122
DSNless if possible...
0
 
LVL 1

Author Comment

by:Cerixus
ID: 24426389
okay forget it, I'll settle for ANYTHING that will connect to a mySQL database on a REMOTE server using VB Script, NOT ASP or asp.net.  I'm talking a .vbs file.
0
 
LVL 1

Author Comment

by:Cerixus
ID: 24426410
Right now this is what I have, but I keep getting the error:

"[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
set mycon = CreateObject("ADODB.Recordset")
mycon.ActiveConnection = "dsn=ServerName;uid=username;pwd=password;"
mycon.Source = "SELECT ServerName FROM serverteam.servers"
mycon.CursorType = 0
mycon.CursorLocation = 2
mycon.LockType = 3
mycon.Open()
mycon_numRows = 0
 
Do while (not mycon.eof) and (intCount < 5)
	msgbox mycon("ServerName")
	mycon.movenext
Loop

Open in new window

0
 
LVL 3

Accepted Solution

by:
Cameron_S earned 2000 total points
ID: 24426915
The only way I have been able to do it was via DSN, so you will need to download an ODBC DSN connector for it.

I also tried this website back in the day for connecting via mySQL within VBS: http://www.connectionstrings.com/mysql#31

Here is an article as well: http://www.visualbasicscript.com/m_36318/tm.htm

...and finally, this forum has some interesting posts: http://forums.nicelabel.com/viewtopic.php?t=886&sid=23c9ec945f5ac2985d4db7edb6e879e2
0
 
LVL 1

Author Comment

by:Cerixus
ID: 24426988
Yeah, I came across all three of those links in my searches, but still had no luck.  I went ahead and just ran it locally form the server with the mysql database.  It's just a one (or two) time script to export everything to a MSSQL server anyway, so I guess I won't worry about it.

Thanks.
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question