Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2005, 02:48 PM
Authorized User
 
Join Date: Jan 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trimming Words

Hi

I'm not sure of the correct jargon to use to explain my question but...

I have a memo field in my database which has, in some cases, too much content to pull out on a specific page, so I am trying to find a way to only allow a certain amount of this content to be shown, which will then end in a link saying something like - click here for more information, which will then in turn, go to the next page to read all of the information from that field. I have no idea how to accomplish this and wondered if someone could give me a clue please? :)

 
Old January 19th, 2005, 03:09 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use VBScript Left() Function

Left(string, length)
Returns a specified number of characters from the left side of a string.

something like this..this will return first 50 characters
<%
Dim MemoFieldContent
MemoFieldContent = Left(rs("memofield"),50)
%>

<%=MemoFieldContent%>...<a href="Your Link">Click Here</a>
 
Old January 19th, 2005, 04:23 PM
Authorized User
 
Join Date: Jan 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply, I've tried to impliment it, but get an error message saying "cannot use parenthesis when calling a sub" ? Its probably to do with where I have placed it?

If CurPage = "" Then CurPage = 1
set myRS = server.createObject("ADODB.Recordset")
Left(string, length)
myRS.CursorType = adOpenStatic
myRS.PageSize =3
myRS.Open "SELECT * FROM AllMovies WHERE Genre ='" & strGenre & "'", myConn

myRS.AbsolutePage = CInt(CurPage)

MemoFieldContent = Left(myRS("Summary"),50)
    Image = myRS ("image")
    Summary = myRS ("Summary")
    Certificate = myRS("Certificate")
    RowCount = 0

-------------------------------------------------

Sorry if the code looks a state, trying to get to grips with a 1000 things as once.
 
Old January 19th, 2005, 04:56 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply, I've tried to impliment it, but get an error message saying "cannot use parenthesis when calling a sub" ? Its probably to do with where I have placed it?

If CurPage = "" Then CurPage = 1
set myRS = server.createObject("ADODB.Recordset")
Left(string, length) ***Remove This
myRS.CursorType = adOpenStatic
myRS.PageSize =3
myRS.Open "SELECT * FROM AllMovies WHERE Genre ='" & strGenre & "'", myConn

myRS.AbsolutePage = CInt(CurPage)

    MemoFieldContent = Left(myRS("Summary"),50)
    Image = myRS ("image")
    Summary = myRS ("Summary")
    Certificate = myRS("Certificate")
    RowCount = 0


I just gave you an *idea* how you can accomplish it, but that certainly does not mean it is the only solution and my code snippet was just a pseudo code. Please make sure you are using the correct syntax.


 
Old January 19th, 2005, 05:23 PM
Authorized User
 
Join Date: Jan 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh right, ok. Well, thanks for your idea. ;)

 
Old February 21st, 2008, 02:06 PM
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have to assign it to a variable for the output to be achieved, or yes, you'll get that error (as I found out, myself, trying to use the Replace function). Say you have something and you're trying to get rid of the first character, this is how you'd do it:

    Dim strOU
    Dim OUStringLength
    strOU = ",OU=Users"
    OUStringLength = len(strOU)
    strOU = Left(strOU,OUStringLength-1)

Happy coding!

Tom






Similar Threads
Thread Thread Starter Forum Replies Last Post
Trimming String MacDevv C# 2005 5 May 6th, 2008 08:55 AM
Site map security trimming. weisma BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 December 25th, 2006 11:57 PM
Trimming a query for search arnabghosh Classic ASP Databases 1 May 31st, 2005 07:39 AM
Words Document maha HTML Code Clinic 8 September 29th, 2004 03:08 AM
why I can't use Chinese words? cash JSP Basics 4 February 19th, 2004 10:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.