<% set cnn = server.createobject("ADODB.Connection") cnn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=./wave.mdb" %> <% ' Create and link command object to data connection then set attributes and SQL query Set cmdDC = Server.CreateObject("ADODB.Command") cmdDC.ActiveConnection = cnn cmdDC.CommandText = "SELECT * FROM customer;" cmdDC.CommandType = 1 ' Create recordset and retrieve values using command object Set rsDC = Server.CreateObject("ADODB.Recordset") ' Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1) rsDC.Open cmdDC, , 0, 1 %>

 

 

Results of <%= cmdDC.CommandText %>

<% For Each Item in rsDC.Fields %> <% Next %> <% ' Loop through recordset and display results If Not rsDC.EOF Then rsDC.MoveFirst ' Get the number of fields and subtract one so our loops start at 0 iFieldCount = rsDC.Fields.Count - 1 ' Continue till we get to the end, and while in each loop through fields Do While Not rsDC.EOF %> <% For iLoopVar = 0 to iFieldCount %> <% Next %> <% rsDC.MoveNext Loop %>
<%= Item.Name %>
<%= rsDC.Fields(iLoopVar) %>
<% ' Close Data Access Objects and free DB variables rsDC.Close Set rsDC = Nothing ' can't do a "cmdDC.Close" ! Set cmdDC = Nothing DataConn.Close Set DataConn = Nothing %>