%@enablesessionstate=false%>
<%response.buffer=true%>
dbtablegetrows.asp
<%
' displays a database in table form via GetRows
myDSN="DSN=Student;uid=student;pwd=magic"
mySQL="select * from publishers where state='NY'"
showblank=" "
shownull="-null-"
Set conntemp=Server.CreateObject("adodb.connection")
conntemp.open myDSN
Set rstemp=conntemp.execute(mySQL)
If rstemp.eof Then
Response.Write "No records matched
"
Response.Write mySQL & "
So cannot make table..."
Call CloseAll
Response.End
End If
Response.Write "" & vbCrLf
'Put Headings On The Table of Field Names
For Each whatever In rstemp.fields
Response.Write "" & whatever.name & " | " & vbCrLf
Next
Response.Write "
" & vbCrLf
' Now lets grab all the records
alldata=rstemp.getrows
Call CloseAll
numcols=UBound(alldata,1)
numrows=UBound(alldata,2)
For rowcounter= 0 To numrows
Response.Write "" & vbCrLf
For colcounter=0 To numcols
thisfield=alldata(colcounter,rowcounter)
If IsNull(thisfield) Then
thisfield=shownull
End If
If Trim(thisfield)="" Then
thisfield=showblank
End If
Response.Write ""
Response.Write thisfield
Response.Write " | " & vbCrLf
Next
Response.Write "
" & vbCrLf
Next
Response.Write "
"
%>
<%
Sub CloseAll
rstemp.close
Set rstemp=Nothing
conntemp.close
Set conntemp=Nothing
End Sub
%>