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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a template that lists field information (data types, size, etc.

Status
Not open for further replies.

mokaplanjr

Technical User
Dec 20, 2000
33
US
I have a template that lists field names in a table. Works fine. But I would also like to get datatype and field size information.

Anybody?
 
I've had a quick look and can not find anything
inherant to Coldfusion other than the column
list.
There are two options I can see.
Firstly access the info through an sp and
return a delimited list.
OR - Even Worse
Use ASP with ADO
IF you go for the second option this may help

DIM cnConn
DIM rsRec
DIM strQry
strQry = "Select * FROM my_table"
SET cnConn = Server.CreateObject("adodb.connection")
cnConn.Open dsn
SET rsRec = cnConn.Execute(strQry)
Dim item
FOR EACH item IN rsRec.Fields
Response.Write(&quot;<br>&quot;&item.Name)
Response.Write(&quot;<br>&quot;&item.Value)
Response.Write(&quot;<br>&quot;&item.ActualSize)
Response.Write(&quot;<br>&quot;&item.DefinedSize)
Response.Write(&quot;<br>&quot;&item.NumericScale)
Response.Write(&quot;<br>&quot;&item.Precision)
Response.Write(&quot;<br>&quot;&item.Type)
Response.Write(&quot;<br>etc<br><br>&quot;)
NEXT
SET rsRec = NOTHING
rsRec.Close
SET cnConn = NOTHING
cnConn.Close
 
Apparently, you are all assuming an Access database on a Windows platform.

However, I know of no general solution. We write apps that are database and platform independent. We define a key in the registry (or in a config file on UNIX platforms) that identifies the database that is being used. Each DMBS (such as Oracle, Sybase, SQL Server) uses a different way of storing the data dictionary. But, we can ues a regular SQL query to retrieve the info. It's just that we have a lot of conditional code as the exact query needed depends on the particular DBMS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top