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 strongm 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
 
Have you tried taking the length of the string

iLen = Len(CStr(rsTemp.Fields("ContactMobile"))

HTH,
JC
 
well that's not good because in stead of giving me the legnth determined in the database, that would give me the length of what has been entered.

i've found the solution, i put it dow, tht could help someone else...

rsTemp.Fields("ContactAddress").DefinedSize

DefinedSize property gives the space in the database, and an
ActualSize property gives you the longest data returned. Best regards X-),
Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top