ASP in JavaScript accessing MySQL

CodeGyver
CodeGyver used Ask the Experts™
on
I've been writing a series of ASP pages using JavaScript and I am trying to write the connection string to a MySQL database, but all the examples I find online are written in VBscript.  Try as I might, when I convert the code to what I imagine it should look like in JavaScript, I can't get it to connect.

Here's the ASP I include when a connection is needed.  I need someone to help me fill in the conn_str variable.  If someone could show me a DNS and DSN-less solution, I'd appreciate it.

<%
var conn, conn_str;
conn=Server.CreateObject("ADODB.Connection");
conn_str="";
conn.Open(conn_str);
%>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
conn_str = "Driver={MySQL};Server=192.168.21.52;DATABASE=INETDB;UID=readonly;PWD=MyPassword;"


replace the IP , databasename, and password with your own.
... and possibly the UID also

Commented:
Try this:

OLE DB Data Provider Connection:

conn_str = "Provider=MySQLProv;" & _
           "Data Source=mySQLDB;" & _
           "User Id=myUsername;" & _
           "Password=myPassword"

ODBC DSN-Less Connections:
To connect to a local database

conn_str = "Driver={mySQL};" & _
           "Server=MyServerName;" & _
           "Option=16834;" & _
           "Database=mydb"
 
To connect to a remote database

conn_str = "Driver={mySQL};" & _
           "Server=db1.database.com;" & _
           "Port=3306;" & _
           "Option=131072;" & _
           "Stmt=;" & _
           "Database=mydb;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"

ODBC-DSN:

conn_str = "DSN=mySystemDSN;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"

ODBC - File DSN:

conn_str = "FILEDSN=c:\somepath\mydb.dsn;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"

cheers =0)

Author

Commented:
actually ivanmata, taking that material straight of another website (which coincidently was coded in VB) was no help at all.  I'd seen that site already.  My problem ended up being in the mySQL settings.  knightEknight's solution worked once I got that straighten out.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial