Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 November 20th, 2003, 02:29 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Temp variables????

    strTemp = Replace(RS("Body"), vbCr, " ")
    strTemp = Replace(strTemp, vbTab, " ")
    strTemp = Replace(strTemp, vbLf, " ")
    strTemp = Replace(strTemp, "<br>", " ")
    strTemp = Replace(strTemp, "<p align=justify>", " ")
    strTemp = Replace(strTemp, "<p>", " ")
    strTemp = Replace(strTemp, "</p>", " ")
    strTemp = Replace(strTemp, "</ul>", " ")
    strTemp = Replace(strTemp, "[list]", " ")
    strTemp = Replace(strTemp, "<li>", " ")
    strTemp = Replace(strTemp, "</li>", " ")
    strTemp = Replace(strTemp, "<ul type=disc>", " ")

I am wondering if you guys can help me out, what do these mean and how are they used? I am lost as to where they are getting values from

__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old November 20th, 2003, 03:06 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Who is "they"?

It looks like someone has HTML stored in a database and they are stripping out some of it before doing something with it. That's all that this code is doing. Just a bunch of replaces.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 20th, 2003, 03:18 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I meant by they was the variables themselves. If they are getting the info. from the database, how can I see this if I don't have access to the database? I just don't see how they work, I am a little lost with this code and I don't want to mess it up. I think it's creating a paragraph with a title and picture beside it and the title links to the page that contains the entire article. But if I need to change this how can I. By changing the sql statment,or is it done inside the Database it's self???

Thanks

 
Old November 20th, 2003, 03:57 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Either you are talking about something that you didn't post here, or I'm going blind.

All I see is one line of code that gets a value from a recordset, does a replace on it, and assigns the result to a temp variable. Then it does a whole bunch more replaces on the temp variable.

Are you getting confused by the syntax of those lines?

strTemp = Replace(strTemp, "</p>", " ")

Code is evaluated right to left of the assignment operator, thus this statement is just saying:
Take the value that's in strTemp, replace all occurrences of "</p>" in it with " " then save (assign) it to strTemp.
This is a pretty standard code construct.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 20th, 2003, 04:09 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No you are not going blind what I posted is exactly what you described and I understand what it is doing. What I don't understand is there is no strtemp anywhere else in the code.

    SQLStr="SELECT TOP " & RSNews.recordcount+RSPress.RecordCount+3 & " * FROM EOI WHERE ClosingDate>='" & date() & "' ORDER BY ClosingDate DESC"
    Set RSEOI=Server.CreateObject("ADODB.Recordset")
    RSEOI.Open SQLStr,Application("DBConn"),adOpenKeyset,adLockPe ssimistic,adCmdText

This is the SQl statement that is above the Replace code. So where is strtemp getting it's information from? I know the database but I don't see where, it's just sitting there. I don't think I am making any sense but I don't know how to describe it :( I guess my question is, is this a good way to do it or is there a better way?

 
Old November 20th, 2003, 04:21 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Although not specified anywhere in the thread, I'm going to make the assumption by the code posted that this is an ASP script.

Unless "Option Explicit" is being used at the beginning of this script, that first line of code could very well be the first place you see strTemp.

Someone decided that they needed a temp string so they typed:
strTemp = Replace(RS("Body"), vbCr, " ")
This implicitly instantiated strTemp and set it's value to the result of the replace function. It's as simple as that.

The temp variable in question has nothing to do with SQL. It's in the ASP script.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 20th, 2003, 04:38 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay thanks Peter I understand what you are saying, and the code is in between asp tags I guess I am just not sure how it works. Because if strtemp is a variable then something would have to be passed to that variable. So does it take the (RS("Body"), vbCr, " ") and assign that to the strTemp variable which inturn replaces the variable with (RS("Body"), vbCr, " ")and if that is the case what in the world is (RS("Body"), vbCr, " ")Is it a recordset I am not seeing?
Sometimes I think I know nothing, lol

Thanks for your time

 
Old November 20th, 2003, 04:46 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Not seeing all of the code I have to assume that somewhere in the page RS is getting set to the result of a query. RS is some recordset, and RS("Body") is the value in the "Body" column of that row in the recordset. The value from that is being passed into the source string part of the replace function. vbCr is the "find" part of the replace function and " " is the replace part of the replace function. The final result of the replace function is assigned to strTemp. So on and so forth.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable or parameter twice within the same temp Navy1991_1 XSLT 4 June 9th, 2008 02:29 PM
temp table in query abdusalam Access 5 January 9th, 2008 09:28 AM
#temp table object_id hortoristic SQL Server 2000 1 March 22nd, 2004 08:57 PM
Temp Var in For Each pbernardo XSLT 5 November 14th, 2003 06:45 PM
Locked temp files Paul13 ASP.NET 1.0 and 1.1 Basics 0 June 5th, 2003 10:00 PM





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