Solved

ASP Jscript MySQL Connection String

Posted on 2010-11-21
3
360 Views
Last Modified: 2012-05-10
I have MySQL installed as well as MyODBC installed, configured and testing OK.

I have been unable to locate a working connection string.  I have converted those I found for asp VBscript but they just lock up the page for minutes and minutes until they timeout.

Obviously I am overlooking something (likely incredibly simple) but am stumped.

Any help would be greatly appreciated.
0
Comment
Question by:darahood
  • 2
3 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 34184775
Here's the connection strings I've found: http://www.connectionstrings.com/mysql  None are specific to Jscript.

But it might be an 'escape' problem: http://support.microsoft.com/kb/189206   '\' is used to 'escape' characters in Jscript but since it is used in paths, it must be escaped there also.
0
 

Author Comment

by:darahood
ID: 34184861
Sorry.  Neither of these was helpful.  It is definitely not an 'escape' problem although I do understand where that could be an issue for some users.

The connection strings are already what I have tried.  I am really wondering if it is something outside of the asp/jscript.

Here is the error message I am getting:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I am in the process of researching that but am open to any info you might have.

Thanks again.
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 34185020
I have one that works.  I hacked up a VBScript version from another question and got it to work.  Put in your own DB info and check it out.
<%@ LANGUAGE = JScript %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Old Website List</title>
</head>
<body>
<h1>Old Website List</h1>
<p>
<%
//select database source
var db_server = "yourserver"
var db_name = "your_db"
var db_username = "username"
var db_userpassword = "password"

var connectstr, objConn , objRS, strSQL
var tsConnection, tobjConn , tobjRS

var connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER="+db_server+";DATABASE="+db_name+";UID="+db_username+";PWD="+db_userpassword;


// Execute a SQL query and store the results
// within recordset
	SQLstr = "SELECT * FROM websitelist"
	SQLstr = SQLstr+" ORDER BY DisplayName LIMIT 10"

objConn = new ActiveXObject("ADODB.Connection");
objConn.ConnectionString = connectstr;
objConn.Open();
objRS = objConn.Execute(SQLstr)


%>
</p>
  <div align="left">
    <center>
    <table width="700" height="115" border="2" cellspacing="0" cellpadding="2">
    <tr bgcolor="#CCFFCC">
		<th width="119">Dname</th>
    <th width="175">Name</th>
    <th width="122">WebSite</th>
    <th width="122">Descript</th>
    <th width="117">entry num</th>
    </tr>
<% 		
while(!objRS.EOF) {
 %>
<tr>
<tr bgcolor='#CCFFCC'>
<td><% =objRS.Fields("DisplayName") %></td>
<td><% =objRS.Fields("SortName") %></td>
<td><% =objRS.Fields("WebSite") %></td>
<td><% =objRS.Fields("Descript") %></td>
<td><% =objRS.Fields("ent_num") %></td>
</tr>
<%
objRS.MoveNext;
}
objRS.Close; //Close the database connection

%>

</body>
</html>

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now