Friday, December 14, 2007

How can we know the total of fields (or columns) in the table?

How can we know the total of fields (or columns) in the table?

Every Recordset object has a Field object; it will store all informations about the fields inside the recordset.


The ASP codes are written and described as below:


<%

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

Set rs = Server.CreateObject("Adodb.Recordset")

rs.open "Member",conn,1,3

if Not rs.EOF Then

Response.Write("The Current Recordset have " & rs.fields.count & " fields")

End IF

rs.Close

Set rs = Nothing

%>

No comments: