Professional Web Applications Themes

Getting SQL Text Field Length - ASP Database

Is there a way to retreive the length of a text field (SQL2000)? I would like to validate an entry to ensure its not too long for the space allocated for it in the database but I really don't want to hard-code the current length as it may change. Thanks! Jon...

  1. #1

    Default Getting SQL Text Field Length

    Is there a way to retreive the length of a text field (SQL2000)? I would
    like to validate an entry to ensure its not too long for the space allocated
    for it in the database but I really don't want to hard-code the current
    length as it may change.

    Thanks!
    Jon


    Jon Guest

  2. #2

    Default Re: Getting SQL Text Field Length

    Jon Glazer wrote: 
    A SQL Server text field has no upper limit.

    If it's actually a char or varchar column you are asking about, you can use
    the OpenSchema method which you can read about at msdn.microsoft.com/library
    in the ADO API reference (drill down in the Data Access node in the TOC)

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Guest

  3. #3

    Default Re: Getting SQL Text Field Length

    You can return an empty recordset, and for the field you are interested in,
    lookup the DefinedSize property.

    "SELECT myTextField from myTable WHERE 1=0"

    And then for the recordset

    Rs.Fields("myTextField").DefinedSize

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "Jon Glazer" <com> wrote in message
    news:XOD1d.17440$columbus.rr.com... 
    allocated 


    Manohar Guest

Similar Threads

  1. order query results by field length?
    By cronoklee@hotmail.com in forum MySQL
    Replies: 2
    Last Post: September 19th, 08:59 AM
  2. Query exists? Get size / length of field
    By johnmcgary in forum Coldfusion Database Access
    Replies: 2
    Last Post: July 21st, 06:03 AM
  3. Field Length Help
    By canswim in forum Coldfusion Database Access
    Replies: 2
    Last Post: June 8th, 02:18 PM
  4. Replies: 3
    Last Post: May 13th, 12:15 AM
  5. Field length
    By Bebop & Rocksteady in forum FileMaker
    Replies: 9
    Last Post: July 13th, 01:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139