Forum Moderators: open
The access file is very simple and has 3 colums A, B and C.
I would like to find a way to script it so that this structure is reached for each row:
CODE
<tr>
<td class="tdemright">Column A</td>
<td>Column B</td>
<td>Column C</td>
</tr>
There are 5 'worksheets' in the access file. Manually this would take an awful long time. But since there is a method in this, with scripting it should not be too difficult.
Can anyone help me with this?
I have uploaded the file for your reference, here:
<SNIP>
Many thanks!
Darkelve
[edited by: BlobFisk at 1:44 pm (utc) on Jan. 14, 2005]
[edit reason] No URLs please! See TOS [webmasterworld.com] [/edit]
The following is probably outdated but it works, you need to get the adovbs.inc ADO constants include:
<!-- #include file="adovbs.inc" -->
<%
Dim objRec, selStr, fldCurrent, strCon, bgSwitch, counter
bgSwitch = 0
counter = 0
' This is going to vary from environment to environment, connects with database
set strConn = Server.CreateObject("ADODB.Connection")
strConn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("[your_database_filename.mdb]")
'Select the records
set objRec = Server.CreateObject ("ADODB.Recordset")
selStr = "select * from [tablename]"
'Open record object
objRec.Open selStr, strConn, adOpenStatic, adLockOptimistic
'This writes the table header by traversing the fields
response.write "<HTML><HEAD><TITLE>Database Listing</TITLE></HEAD><BODY>"
response.write "<TABLE CELLPADDING='1'><TR>"
For Each fld In objRec.Fields
response.write "<TD BGCOLOR='#000000' ALIGN='center'><FONT COLOR='#FFFFFF'><B>" & fld.Name & " " & fld.Type & "</B></FONT></TD>"
Next
response.write "</TR>"
'This writes out 50 rows of the records. Change the while to write all
' Use this for all: While not objRec.EOF
While counter < 50
Response.Write "<tr>"
For Each fldCurrent In objRec.Fields
Response.Write "<td nowrap">
If fldCurrent.Value <> "" Then
Response.Write Cstr(fldCurrent.Value) & "</td>"
Else
Response.Write " </TD>"
End If
Next
Response.Write "</tr>"
counter = counter + 1
objRec.MoveNext
wend
objRec.Close
Set objRec = Nothing
response.write "</TABLE><BR><BR>"
%>