Support & FAQ
Support & FAQ
 
 

Support & FAQ

Spørgsmål:

Database forbindelse (mySQL)

Svar:

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:

1 Jens Hansen Nørregade 45, 8000 Århus C
2 Lise Thomsen Skolegade 3, 5000 Odense



Hvordan ville du karakteriserer dette indhold (hvor 5 er bedst)?


Senest opdateret: 10-11-2008, 13:29.
A/S ScanNet - Birkemose Allé 11 - 6000 Kolding - Tlf. (+45) 75 53 35 00 - Fax (+45) 75 53 35 09 - scannet@scannet.dk