Solved

ASP Jscript MySQL Connection String

Posted on 2010-11-21
3
362 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 83

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 83

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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