Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dispalying database without know field names?

Status
Not open for further replies.

brown

Technical User
Nov 24, 2000
4
US
Is there anyway to display the contents of a database table without knowing the field names? Ian Hall
Multimedia Designer
 
Sure Ian,

var rs = Server.CreateObject("ADODB.Recordset");
rs.Open("select * from mytable", ....);

Response.Write(&quot;<table border=1>&quot;);
while (!rs.EOF){
Response.Write(&quot;<tr>\r\n&quot;);
for( nCol=0; nCol<rs.Fields.Count; nCol++){
Response.Write(&quot;<td>&quot; + rs(nCol) + &quot;</td>\r\n&quot;);
}
Response.Write(&quot;</tr>&quot;);
}
Response.Write(&quot;</table>&quot;);

Good luck
-pete
 
More...
Append this block after &quot;while...&quot; and you will show field names

Response.Write &quot;<TR>\r\n&quot;
For i = 1 To rs.Fields.Count
Response.Write &quot;<TD>&quot;
Response.Write rs.Fields(i - 1).Name
Response.Write &quot;</TD>\r\n&quot;
Next
Response.Write &quot;</TR>&quot;

Best regards,
Ilguizar Rizaev


 
Sorry, do it not after but before &quot;while...&quot;
IR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top