Asp Codes
ActiveX
ADO
Array
Code Snippets
Components
Data Access
Date Time
Files
Graphics
HTML Formatting
Mathematics
Miscellaneous
Sessions
SQL
Strings
Techniques
XML
Asp > SQL sample source codes
Table Database Display via GetRows
Table Database Display via GetRows <%@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 %>
Privacy Policy
|
Link to Us
|
Links