Programming, error messages and sample code

How to connect to MySQL via ASP

Programming, error messages and sample code > sample code

<% 
Dim cnnSimple  ' ADO connection 
Dim rstSimple  ' ADO recordset 
Set cnnSimple = Server.CreateObject("ADODB.Connection") 
 
' ODBC connection string 
cnnSimple.Open "Driver={MySQL ODBC 5.1 Driver};Server=MySQL Server;Database=Database name;User=DB Login; Password=DB Password;Option=3;" 
 
Set rstSimple = cnnSimple.Execute("SELECT * FROM table1") 
 
 
%> 
<P> Connecting to MySQL DB with ODBC </P> 
 
<table border="1"> 
<% 
Do While Not rstSimple.EOF 
 %> 
 <tr> 
  <td><%= rstSimple.Fields("column1").Value %></td> 
  <td><%= rstSimple.Fields("column2").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 
%>