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

how to get fields length ???

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all,
i have a VB program that uses a sql server database.
i put a sample of my code :


strSQL = "SELECT ContactLName, ContactAddress, ContactPhWork, ContactMobile, ContactFax, ContactEmail FROM T_CONTACTS WHERE ContactID = 15;"
Set rsTemp = New ADODB.Recordset
rsTemp.Open strSQL, MyConn, adOpenStatic

then i get back the results of my query with this :

CStr(rsTemp.Fields("ContactAddress")
CStr(rsTemp.Fields("ContactMobile") ...
for each field.

i take them to put them in a web page.
what i need to know is the size of each field, as described in the database.
an exemple :
in the database the size of the field ContactAddress is 200.
so the text box should get 200 characters max too. and if someone changes the size of the field in the database, that should be automaticaly changed in the code. that's why i'd like to know how to get the lenght of a field, is there a varialbe, a property, something that returns the max lenght of each field ???.

any idea ??? X-)
best regards,
elise Best regards,
Elise
 
What you want to use is the
Code:
DefinedSize
property of the feild object. This is the size in bytes of the underlying data,. As long as you are not using Unicode on the server then 1 byte = 1 char.

Code:
lngLength = rsMyRecordset("MyField").DefinedSize

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top