replace function

  • hi,

    izit that 2 replace functions cannot used at one textfield???

    CompanyNameTF = trim(request.form("CompanyNameTF"))

    CompanyNameTF = replace(request.form("CompanyNameTF"), "&", "And")

    CompanyNameTF = trim(request.form("CompanyNameTF"))

    CompanyNameTF = replace(request.form("CompanyNameTF"), "'", "''")

    it only work for single quote then for the '&' it is not replaced...

    pls giv some advice....thank you..

    =)

  • Hi,

    I assume that you are using the VBScript Replace function...that works fine on my system here...there's no problem replacing the "&" by "AND"...or is there something I am missing out here??

  • hi

    if i did not put the replace for single quote, the replace for & can work but when two replace functions put together, then onli replace for single quote work so i m tinking how to make both work...

    pls give me some advice... thanx =)

  • I think I get it now...

    CTF = Request.form("CompanyNameTF")

    CTF = Replace(Replace(CTF,"&","AND"),"'","''")

    I hope this is what you are looking for.....

  • hi

    i can replace the '&' to 'And' and also for the single quote to 2 single quotes function

    the code below is a pulldown menu that capture those company name inside. for those company name which need to use replace function would aso be in the pulldown menu but when u selected the company name that used replace single quote to 2 single quote function it will say no record found.

    While NOT rsQuery.EOF

    If rsQuery("Company_Name") <> "" Then

    response.write "<option "

    If CompanyName <> "" Then

    If trim(CompanyName) = trim(rsQuery("Company_Name")) Then

    response.write "SELECTED "

    End If

    End If response.write "value='"

    response.write trim(rsQuery("Company_Name"))

    response.write "'>"

    response.write trim(rsQuery("Company_Name"))

    response.write "</option>"

    End If

    rsQuery.MoveNext()

    Wend

    rsQuery.close()

    Set rsQuery = Nothing

    pls give me some advice ... thank alot =)

    Edited by - heero on 08/01/2002 03:30:48 AM

  • I hope you found the answer long ago to this question. I'm having the same problem.

    OK - This is fixed. It was the presentation layer pagination cuttin off records.

     

    Ignore the rest of this post!

     

    This SQL worked in Query Analyzer:

    SELEct prsn_id,last_nm from be_prsn c where

     (REPLACE(c.last_nm, ' ', '') like 'Obrien'

     OR REPLACE(c.last_nm, CHAR(39), '') like 'Obrien'

     OR REPLACE(c.last_nm, CHAR(39)+CHAR(32), '') like 'Obrien'

     OR REPLACE(c.last_nm, CHAR(32)+CHAR(39), '') like 'Obrien'

     OR REPLACE(c.last_nm, '-', '') like 'Obrien'

     OR c.last_nm like 'Obrien')

     order by prsn_ID

     

    But it does not work in Forte. This is a stub where clause from  DBGetaoBEPrsnByOrgIdNDtNBVEmplyPrsn

     
     and (REPLACE(c.last_nm, ' ', '') like :TempText

      OR REPLACE(c.last_nm, CHAR(39), '') like :TempText

      OR REPLACE(c.last_nm, CHAR(39)+CHAR(32), '') like :TempText

      OR REPLACE(c.last_nm, CHAR(32)+CHAR(39), '') like :TempText

      OR REPLACE(c.last_nm, '-', '') like :TempText 

      OR c.last_nm like :TempText)

     
    The parameters that get passed to SQL Profiler look very strange i would guess that ODBC is screwing it up.
     
    This is a search for obrian in SQL Profiler from Forte
    declare @P1 int

    set @P1=180150022

    declare @P2 int

    set @P2=8

    declare @P3 int

    set @P3=1

    declare @P4 int

    set @P4=2

    exec sp_cursorexecute 11, @P1 output, @P2 output, @P3 output, @P4 output, 48, '2006/10/06', '2006/10/06', 'obrien%', 'obrien%', 'obrien%', 'obrien%', 'obrien%', 'obrien%', 'O''BRIEN', 48, '2006/10/06', '2006/10/06', 'obrien%', 'obrien%', 'obrien%', 'obrien%', 'obrien%', 'obrien%', 'O''BRIEN', 'O''BRIEN', 'JAMES'

    select @P1, @P2, @P3, @P4

    As you can see it is hard to tell what is going on here.
     
    This is a search from QA in Profiler:
     
    SELEct prsn_id,last_nm from be_prsn c where

     (REPLACE(c.last_nm, ' ', '') like 'Obrien'

     OR REPLACE(c.last_nm, CHAR(39), '') like 'Obrien'

     OR REPLACE(c.last_nm, CHAR(39)+CHAR(32), '') like 'Obrien'

     OR REPLACE(c.last_nm, CHAR(32)+CHAR(39), '') like 'Obrien'

     OR REPLACE(c.last_nm, '-', '') like 'Obrien'

     OR c.last_nm like 'Obrien')

     order by prsn_ID

    It appears that it will not replace the two character string correctly through Forte.
     
    help!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply