Mail & Web
Outsourcing
Shop & CMS
Eksemplet nedenfor viser hvordan forbindelsen til en mySQL database etableres.
<html> <head> <title>Database forbindelse</title> </head> <body> <% Set connection = Server.Createobject("ADODB.Connection") ' --- Database forbindelse --- connectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=servernavn; " &_ "DATABASE=databasenavn; UID=brugernavn; PWD=password" set rs = Server.CreateObject("ADODB.Recordset") connection.Open connectionString rs.ActiveConnection = connection ' --- SQL forespørgelse --- Set RS = Connection.Execute("SELECT * FROM Kunder") %> <table border="1" width="400"> <% ' --- Udskriv data --- Do While Not RS.EOF %> <tr> <td><%=RS("ID")%></td> <td><%=RS("Navn")%></td> <td><%=RS("Adresse")%></td> </tr> <% RS.MoveNext Loop RS.close Connection.Close Set RS = nothing Set Connection = nothing %> </table> </body> </html>
Eksempel: