Results 1 to 8 of 8

Thread: Limit field display length

  1. #1
    Join Date
    Oct 2002
    Posts
    28

    Limit field display length

    I have a field with a length set to 255. I would like to just display the first 15 characters. I'm sure I will do it with MagicCell but I can't figure out how.

    Thanks,
    Dan

  2. #2
    Join Date
    Oct 2002
    Posts
    933
    Classic or Tornado ?

    FK

  3. #3
    Join Date
    Oct 2002
    Posts
    28
    Using Clasic

  4. #4
    Join Date
    Oct 2002
    Posts
    93
    Try this program:

    <%
    Set X=Server.CreateObject("ASP.DB")
    X.dbUnit=188
    X.dbMode = "Grid"
    X.dbDSN = "nwind"
    X.dbSQL = "Select Title, Left(Title,15) as myShortTitle from Employees"
    X.ASPdb
    %>

    Take care,
    John

  5. #5
    Join Date
    Oct 2002
    Posts
    933
    Is this a generic solution? That means, does this query works on ALL DBs ?

    If yes then it is a good solution. If not, then the MagicCell solution should be used. One of the important goal of ASP-db is to make the code works across platform.


    FK

  6. #6
    Join Date
    Oct 2002
    Posts
    28

    Field Length and MagicCell

    Is there a way to do it with MagicCell?

  7. #7
    Join Date
    Oct 2002
    Posts
    933
    I found this sample code. See whether it works for you ->

    <%
    Response.write("THIS FORMAT (all CAPS) WORKS:")
    Set x = Server.CreateObject("ASP.db")
    x.dbUnit = 11
    x.dbDSN = "NWIND"
    x.dbSQL = "Select FirstName,LastName FROM Employees"
    x.dbMode = "GRID"
    x.dbMagicCell = "FirstName,,Format=[>];"
    x.ASPdb

    Response.write("THIS FORMAT (first 3 char except if = Andrew) WORKS:")
    x.dbUnit = 12
    x.dbDSN = "NWIND"
    x.dbSQL = "Select FirstName,LastName FROM Employees"
    x.dbMode = "GRID"
    x.dbMagicCell = "FirstName,,(#FirstName#|NE|Andrew||#FirstName:3#) ;"
    x.ASPdb


    Response.write("THIS FORMAT (first 3 char except if = Andrew, <B>and all CAPS</B>)")
    x.dbUnit = 13
    x.dbDSN = "NWIND"
    x.dbSQL = "Select FirstName,LastName FROM Employees"
    x.dbMode = "GRID"
    x.dbMagicCell = "FirstName,,(#FirstName#|NE|Andrew||#FirstName:3:F ormat=[>]#)"
    x.ASPdb

    Response.write("Another test")
    x.dbUnit = 14
    x.dbDSN = "NWIND"
    x.dbSQL = "Select FirstName,LastName, HireDate, Birthdate FROM Employees"
    x.dbMode = "GRID"
    x.dbMagicCell = "FirstName,,#Firstname::Format=[>]#; HireDate,,#HireDate::Format=[mmm-dd-yy]#; Birthdate,,#Birthdate::mmm-dd-yyyy#"
    x.ASPdb
    %>

  8. #8
    Join Date
    Oct 2002
    Posts
    32
    Dan
    There are 2 ways to use MagicCell. One will give you a "..." after the first n characters, the other will not. Example:
    display the first 5 characters of "Browser":
    1) Brows...
    2) Brows

    Here is the code:

    MyDb.dbMagicCell = "(;$)LastName$$#LastName:5#;" &_
    "FirstName$$<script language=""JavaScript"">" &_
    "FN=new String(""#FirstName#"")" & chr(13) &_
    "document.write(FN.substring(0,5))" & chr(13) &_
    "</script>"

Posting Permissions

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