Query MySQL database in ASP

DETAILS

<%

Dim cnnSimple  ' ADO connection
Dim rstSimple  ' ADO recordset
Set cnnSimple = Server.CreateObject("ADODB.Connection")

' DSN
cnnSimple.Open "DSN=<username>_mysqlConn;"

Set rstSimple = cnnSimple.Execute("SELECT * FROM tblTest")


%>
<P> Connecting to mySQL DB with ODBC DSN </P>

<table border="1">
<%
Do While Not rstSimple.EOF
 %>
 <tr>
  <td><%= rstSimple.Fields("id").Value %></td>
  <td><%= rstSimple.Fields("name").Value %></td>
 </tr>
 <%
 rstSimple.MoveNext
Loop
%>
</table>
<%
' Close our recordset and connection and dispose of the objects rstSimple.Close Set rstSimple = Nothing cnnSimple.Close Set cnnSimple = Nothing

cnnSimple.close
%>

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Query a SQL database with ASP using a DSN-less connection

DETAILS<%Dim cnnSimple  ' ADO connectionDim rstSimple  ' ADO recordsetSet cnnSimple...

Query MS SQL Database with PHP

DETAILSBelow is a simple PHP script to demonstrate how to connect to a MS SQL database using an...

Query MySQL Database in ASP.net

DETAILS<%@ Page Language="VB" %><%@ import...

SQLXML code sample in ASP

DETAILS<%Response.ContentType = "text/xml"Dim oCmd, sSQL sSQL =...

Query an Access database with ASP using a DSN-less connection.

DETAILS<%Dim cnnSimple  ' ADO connectionDim rstSimple  ' ADO recordsetSet cnnSimple...