ASP source codes for accessing the MySQL database

Here is an example of ASP (Visual Basic) code

<%

   Dim cn
   Dim rs

   Set cn = Server.CreateObject("ADODB.Connection")
   Set rs = Server.CreateObject("ADODB.Recordset")

   ' Replace the values of the server, database, uid and pwd fields in the following connection string
   ' with the respective values on your control panel: server, database, username, password
   cn.Open "driver={MySQL ODBC 3.51 Driver};" & _
   "server=127.0.0.1;database=m1d1;uid=m1d1;pwd=ehd71a9soduv62sw;"

   rs.Open "SELECT name FROM users",cn
      Do Until rs.EOF
         Response.Write rs("name") & "<br />"
         rs.MoveNext
      Loop
   rs.Close
   Set rs = Nothing

   cn.Close
   Set cn = Nothing

%>

back