How to use ASP & SQL Server Get Field Name This is tutorial asp developers how to using ASP get field name from a SQL Server database.
ShotDev Focus:
- ASP & SQL Server Get field name from table.
Example
asp_sqlserver_list_table.asp
<% Option Explicit %> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <% Dim Conn,strSQL,objRec,arrField Set Conn = Server.Createobject("ADODB.Connection") Conn.Open "Driver={SQL Server};Server=localhost;Database=mydatabase;UID=sa;PWD=;" strSQL = "SELECT * FROM customer" Set objRec = Server.CreateObject("ADODB.Recordset") objRec.Open strSQL, Conn, 1,3 Response.write "<b>Table customer have "& objRec.Fields.Count &" Fields.</b><br>" For Each arrField In objRec.Fields Response.write arrField.Name & "<br>" Next objRec.Close() Conn.Close() Set objRec = Nothing Set Conn = Nothing %> </body> </html>
Create a asp file and save to path root-path/myasp/
Run
http://localhost/myasp/asp_sqlserver_list_table.asp
Screenshot