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 February 26th, 2004, 06:08 AM
Authorized User
 
Join Date: Feb 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Whats wrong with this code?

Hi, now this is strange...

Problem: The "introbox_text" can not be displayed when the yellow code is added, but it works fine when I delete the yellow code. It seams that there can only be one string count, but Im not sure. Can Anybody see the problem with this code, couse I really don't.

<%
...

Dim strTitleLenghtTwo 'Returning the lenght of a string
Dim strIntroTextLenghtTwo 'Returning the lenght of a string

strTitleLenghtTwo = Len(rsTextTwo("Text_title"))
strIntroTextLenghtTwo = Len(rsTextTwo("Introbox_text"))

...
%>

<% = Rtrim(left(rsTextTwo("Text_title"), 18)) %><% If strTitleLenghtTwo > 18 Then %>...<% End if %>

<% = Rtrim(left(rsTextTwo("Introbox_text"), 200)) %><% If strIntroTextLenghtTwo > 200 Then %>...<% End if %>

As you can see I have used the same method twice to achieve the same goal with both the title and intro text.

 
Old February 26th, 2004, 06:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I literally cannot see what's wrong. I can't see the yellow code.....

How about making it bold instead of yellow?

Can you also show the code for the Recordset? And what kind of error are you getting?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 26th, 2004, 06:35 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Are either of these fields Memo (or Text in SQL)? If so there are known problems with repeated access. The best thing to do is to save the value to a local variable and then use that:
Code:
Dim strTitleTwo 
Dim strTitleLenghtTwo       'Returning the lenght of a string
Dim strIntroTextLenghtTwo  'Returning the lenght of a string
Dim strIntroTextTwo  

strTitleTwo = rsTextTwo("Text_title")
strTitleLenghtTwo = Len(strTitleTwo)
strIntroTextTwo = rsTextTwo("Introbox_text")
strIntroTextLenghtTwo = Len(strIntroTextTwo)
Then use strTitleTwo and strIntroTextTwo later on in the page.

Hope this helps, please don't choose yellow next time, I couldn't read it at all :)

--

Joe
 
Old February 26th, 2004, 07:38 AM
Authorized User
 
Join Date: Feb 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okey, here's the code again (yellow is now replaced with bold)...

<%
...

Dim strTitleLenghtTwo 'Returning the lenght of a string
Dim strIntroTextLenghtTwo 'Returning the lenght of a string

strTitleLenghtTwo = Len(rsTextTwo("Text_title"))
strIntroTextLenghtTwo = Len(rsTextTwo("Introbox_text"))

...
%>

<% = Rtrim(left(rsTextTwo("Text_title"), 18)) %><% If strTitleLenghtTwo > 18 Then %>...<% End if %>

<% = Rtrim(left(rsTextTwo("Introbox_text"), 200)) %><% If strIntroTextLenghtTwo > 200 Then %>...<% End if %>

I will try to use two more variables like you said...

 
Old February 26th, 2004, 07:58 AM
Authorized User
 
Join Date: Feb 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by joefawcett
Code:
Dim strTitleTwo 
Dim strTitleLenghtTwo       'Returning the lenght of a string
Dim strIntroTextLenghtTwo  'Returning the lenght of a string
Dim strIntroTextTwo  

strTitleTwo = rsTextTwo("Text_title")
strTitleLenghtTwo = Len(strTitleTwo)
strIntroTextTwo = rsTextTwo("Introbox_text")
strIntroTextLenghtTwo = Len(strIntroTextTwo)
Then use strTitleTwo and strIntroTextTwo later on in the page.

Joe
Thanks Joe! I did just like you said and it worked. Not that I see why it did'nt work before, but now at least I don't have to throw my computer out of the window in pure frustratioin :D

 
Old February 26th, 2004, 09:19 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You didn't answer the part about memo fields though...

--

Joe
 
Old February 26th, 2004, 09:40 AM
Authorized User
 
Join Date: Feb 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by joefawcett
 You didn't answer the part about memo fields though...

--

Joe
The fields are from an Access database, witch I have opened with SQL statments... Memo... don't really know what that is






Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with this code? hertendreef Visual Basic 2005 Basics 0 March 2nd, 2007 10:29 AM
Whats wrong? Agentofnight Beginning PHP 3 April 17th, 2005 04:11 AM
Whats wrong with the GUI display Sandz Java GUI 1 February 5th, 2005 08:28 AM
whats wrong with this code? sand133 VB.NET 2002/2003 Basics 2 September 12th, 2004 10:07 PM
whats wrong with this code ? qwprince Classic ASP Basics 5 July 27th, 2003 07:46 PM





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