home *** CD-ROM | disk | FTP | other *** search
- <%
- '////////////////////////////////////////////////////////////////////
- '// //
- '// NetObjects ScriptBuilder ASP Samples //
- '// Sample : Data Access using ADO //
- '// //
- '////////////////////////////////////////////////////////////////////
-
- ' DESCRIPTION: This sample shows how to connect to a database,
- ' execute a SQL query, and then display the retrieved data.
- %>
-
- <%
- ' To use a different DSN, table or where clause, just modify the values below.
-
- DSN = "PDP"
- TableName = "Employee"
- WhereClause = "EmailName = 'Sal'"
- %>
-
- <HTML>
- <HEAD>
- <TITLE>Data Access Sample</TITLE>
- </HEAD>
- <BODY BGCOLOR=#FFFFFF>
- <H3>Data Access Sample</H3>
- <%
- Set Conn = Server.CreateObject("ADODB.Connection")
- Conn.Open DSN
- Set RS = Conn.Execute("SELECT * FROM " & TableName & " WHERE " & WhereClause)
- %>
- <P>
- <TABLE>
- <TR BGCOLOR="blue">
- <% For i = 0 to RS.Fields.Count - 1 %>
- <TD><B><% = RS(i).Name %></B></TD>
- <% Next %>
- </TR>
- <% Do While Not RS.EOF %>
- <TR BGCOLOR="yellow">
- <% For i = 0 to RS.Fields.Count - 1 %>
- <TD VALIGN=TOP><% = RS(i) %></TD>
- <% Next %>
- </TR>
- <%
- RS.MoveNext
- Loop
- RS.Close
- Conn.Close
- %>
- </TABLE>
- </BODY>
- </HTML>