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

How do I determine the field size using ASP

Status
Not open for further replies.

WartookMan

Technical User
Nov 24, 2003
346
AU
I have searched Google. I have searched multiple groups on Tek-Tips... but without success.

I would like to retrieve a field's "Field Size" property using ASP. Is this possible? I want to be able to use it as a first-line trap, to set the "MAXLENGTH" attribute of an INPUT field on an HTML form.

I have managed to access a field's "Description" Property, and whether it can be Nullable or not, but not it's size. I have even tried outputting ALL Properties for all Fields for all Tables available, but there doesn't seem to be a Property for the size!

This was my code for the Properties available:
Code:
Dim objTable, objColumn, objProp
For Each objTable in objADOXDatabase.Tables
	If objTable.Type = "TABLE" then 
		Response.Write objTable.Name & "<br>"

		For Each objColumn in objTable.Columns
			Response.Write "&nbsp;&nbsp;&nbsp;" & objColumn.Name  & " - " & objColumn.Attributes & "<br>"
			
			For Each objProp in objColumn.Properties
				Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & objProp.Name & " - " & objProp.Value & " - " & objProp.Attributes & "<br>"
			Next
		Next

    Response.Write "<p>"
  End If
Next

Any help / ideas would be most appreciated.

Pete.

Web Developer & Aptrix / IBM Lotus Workplace Web Content Management (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
Hi,

I may stand corrected, but I don't think there are any impediments to opening a schema recordset while using ASP. You will want to return the schema as an ADO recordset.

Now as to which of the schemas to use for field size. I don't have anything at the moment to back up a fuzzy memory, but I think adSchemaColumn or adSchemaTable should get you field sizes.

One thing to look forward to: all numeric fields will return a zero. Memo fields won't return anything and I think there is some quirk about boolean fields.

Cheers,
Bill
 
Hi!

Don't know anything about ASP, there are some fora for that, where you might get lucky (forum333, forum855).

But from Access, I think you'll be able to access amongst other, the .Type property and the .DefinedSize property of fields thru the .Fields collection of a recordset.

[tt]for idx = 0 to rs.fields.count-1
debug.print rs.fields(idx).type, rs.fields(idx).definedsize
next idx[/tt]

Text fields, I believe is type 202 (adVarWChar)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top