My Account   Contact Us    
  
» HomeProductsSupportDeveloper CommunityCompany
Get record fron DB
Author: Sierra
Category: ASP
Connection to DB, create Record Set and write record

<HTML>
<HEAD>
<TITLE>PROVA ASP</TITLE>
</HEAD>
<BODY>
<%
'Creo la connessione al Database
Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("test.mdb")
Conn.Open DSNtest

'creo l'oggetto Recordset
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

'Eseguo la query SQL SELECT
rs.Open "SELECT * FROM Studenti", conn

'Controllo di errore
If rs.eof then
 response.write "non ci sono record"
    response.end
Else
%>
<div align="center">
  <center>
  <table border="1" bordercolor="#111111" width="50%" id="AutoNumber1">
  <%
'Visualizzazione recor
    Do While not rs.EOF
%> <tr>
    <td width="25%">
    <%ID = rs("ID")
 response.write ID %>&nbsp;</td>
    <td width="25%">
    <%Nome = rs("Nome")
 response.write Nome %>&nbsp;</td>
    <td width="25%">
    <%Cognome = rs("Cognome")
 response.write Cognome %>&nbsp;</td>
    <td width="25%">
    <%Data = rs("Data")
   response.write Data %>&nbsp;</td>
    </tr> 
<%  rs.MoveNext
    Loop
%>  </table>
<%  
'Chiusura elementi
 rs.close
 set rs=nothing
 End If
 Conn.close
 set Conn = nothing
%>
  </center>
</div>
</BODY>
</HTML>



Content Management Powered by ActivEdit  ActivEdit Browser Based WYSIWYG HTML Editor

More Code Samples

Sign up for our newsletter: | Subscribe with RSS: RSS
© ActivSoftware 1999 to 2005 | Privacy Statement