Friday, December 14, 2007

How to get each of the field type?

How to get each of the field type?

Each field has their own properties; we can use the "for...loop" to get the type of each field.


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

For Each oField In rs.Fields

Select Case oField.type

Case 202

Response.Write("Text
")

Case 203

Response.Write("Memo
")

Case 3

Response.Write("AutoNumber
")

Case 11

Response.Write("Yes/No
")

Case 11

Response.Write("Yes/No
")

End Select

Next

End IF

rs.Close

Set rs = Nothing

%>

No comments: