Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to get fields length ???

how to get fields length ???

how to get fields length ???

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("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 ???
best regards,

Best regards,

RE: how to get fields length ???

Have you tried taking the length of the string

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


RE: how to get fields length ???

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...


DefinedSize property gives the space in the database, and an
ActualSize property gives you the longest data returned.

Best regards ,

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close