Query MySQL database in ASP

                                                        
1
2
3 <%
4
5 Dim cnnSimple ' ADO connection
6 Dim rstSimple ' ADO recordset
7 Set cnnSimple = Server.CreateObject("ADODB.Connection")
8
9 ' DSN
10 cnnSimple.Open "DSN=_mysqlConn;"
11
12 Set rstSimple = cnnSimple.Execute("SELECT * FROM tblTest")
13
14
15 %>
16 <P> Connecting to mySQL DB with ODBC DSN P>
17
18 <table border="1">
19 <%
20 Do While Not rstSimple.EOF
21 %>
22 <tr>
23 <td><%= rstSimple.Fields("id").Value %>td>
24 <td><%= rstSimple.Fields("name").Value %>td>
25 tr>
26 <%
27 rstSimple.MoveNext
28 Loop
29 %>
30 table>
31 <%
32 ' Close our recordset and connection and dispose of the objects rstSimple.Close Set rstSimple = Nothing cnnSimple.Close Set cnnSimple = Nothing
33
34 cnnSimple.close
35 %>
36
37
38

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Sample Code on how to send email using Classic ASP

If you are using ASP to send email on our emailserver, please avoid using CDONTS. We no longer...

Redirect a subdomain to a subdirectory

You can redirect a subdomain to a subdirectory by using ASP or ASP.net code. When the...