-
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
-
-
-
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
-
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
-
Field Length and MagicCell
Is there a way to do it with MagicCell?
-
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
%>
-
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
-
Forum Rules
|
|