Knowledge Base

HOME: ASP
ASP - Active Server Pages


1. ASP and ODBC and mySQL

To connect to your mySQL database via ASP, first install ASP and ODBC via the ASP section of your Account Manager. Then there are five values that you will need in your ASP code:
1. Driver -- must be "{Mysql}"
2. Server -- must be "localhost"
3. Database -- Your database name. Check the mySQL section of your Account Manager. example: metapros_net
4. UID -- your mySQL username. Usually the same as your Account Manager username.
5. PWD -- your mySQL password. Usually the same as your Account Manager password.


To test to see if ODBC is working for ASP, and a sample page of how to set it up, cut and paste the code from --- to --- into a file called test.asp and view it through the web. You will have to replace the following values with legitimate information:

$db, $user, $pass, $table, $sometest.field

$sometest.field is a field in table $table that you are attempting to pull test data from

---
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
connect_string = "Driver={Mysql}; Server=localhost; Database=$db; UID=$user; PWD=$pass"
set dbConn = server.createObject("ADODB.connection")
dbConn.open connect_string
mySQL="select * from $table"
set rstemp=dbConn.execute(mySQL)
response.write name
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<% Do While Not rstemp.EOF%>
<h2>
<%= rstemp.Fields("$sometest.field") %>
<%= rstemp.Fields("$some.other.test.field") %>
</h2>
<% rstemp.MoveNext
Loop
%>
</body>
</html>
---


Updated: November 5, 2003


- New Hosting Client -
- Knowledge Base -
- Acct Manager Demo -
- Policies -
      Acceptable Use
      Billing
- Support Form -



© 2009 MetaPros Website Solutions.
Questions, concerns or comments?