- ASP - Database Table Display
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


Display an Excel DB
Excel can act as a database. It's not the fastest or the best. However, for small data bits on a server where the chance for significant simultaneous traffic is not likely excel can perform many of the basic tasks that can be accomplished in Access or SQL Server, but on a much smaller scale. For this example, we've taken our db on the career statistics of hank Greenberg and place it insided an excel spreadsheet. We've also named the range of his statistics, including the header rows hamerin_hank. This is not to be confused with naming a sheet in an excel. You must highlight the full range of cells you want to query. From the toolbar in excel select insert -> Name -> define. Name the cell range (I would avoid spaces and special characters) and click OK. Other the directing the query to the excel driver instead of the Access data most everything is the same as displaying an Access db.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<title> an Excel in ASP)</title>
<body bgcolor="#FFFFFF">
<!--#include file=""-->

' Import constants from specifically 
'adOpenStatic and adLockPessimistic 

'Name of the excel file being displayed

' Create a server connection object
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "DBQ=" & Server.MapPath(exceldb) & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Query to run against the exceldb
' hamerin_hank is the name of the 
' cell range as defined in excel
sql="select * from hammerin_hank;"

' Execute the sql
rs.Open sql, cn, _
adOpenStatic, adLockPessimistic

<table border=1 align=center>
<caption>Hank Greenberg Career Statistics</caption><%
For counter = 0 To rs.fields.count - 1 %>

<% ' Write out the field names 
response.write rs.fields.item(counter).name %>

' Move to the next field

' Move to the first record

' Write out the record set
do while not rs.eof %>

' Loop through all of the fileds
for counter = 0 to rs.fields.count - 1
<td align=right>
<% ' Write out the field values 
response.write rs.fields.item(counter).value %>

' Move to the next field

' Move to the next record


' Kill the recordset
Set rs = nothing
' Kill the connection
Set cn = nothing





ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3