You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.5 KiB
Plaintext

<%@enablesessionstate=false%>
<%response.buffer=true%>
<html><head>
<TITLE>dbtablegetrows.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
<%
' 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<br>"
Response.Write mySQL & "<br>So cannot make table..."
Call CloseAll
Response.End
End If
Response.Write "<table border='1'><tr>" & vbCrLf
'Put Headings On The Table of Field Names
For Each whatever In rstemp.fields
Response.Write "<td><b>" & whatever.name & "</B></TD>" & vbCrLf
Next
Response.Write "</tr>" & 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 "<tr>" & 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 "<td valign=top>"
Response.Write thisfield
Response.Write "</td>" & vbCrLf
Next
Response.Write "</tr>" & vbCrLf
Next
Response.Write "</table>"
%>
</body></html>
<%
Sub CloseAll
rstemp.close
Set rstemp=Nothing
conntemp.close
Set conntemp=Nothing
End Sub
%>