Parsing Data in ASP

Discussion in 'ASP General' started by Lisa, Aug 31, 2004.

  1. Lisa

    Lisa Guest

    I have a select statement that gives me the following results (for
    example) "test documentation/software product version document.doc" I
    need to parse the data to only grab everything between the "/" and
    ".". So, in other words, "software product version document" - I have
    absolutley no idea how to do this - can anyone help????

    Thanks in advance!
    Lisa
     
    Lisa, Aug 31, 2004
    #1
    1. Advertising

  2. Lisa wrote:
    > I have a select statement that gives me the following results (for
    > example) "test documentation/software product version document.doc" I
    > need to parse the data to only grab everything between the "/" and
    > ".". So, in other words, "software product version document" - I have
    > absolutley no idea how to do this - can anyone help????
    >
    > Thanks in advance!
    > Lisa

    I need to ask: is this truly represtative of your data? Could there be more
    than one "/", or more than one "."? If so, you need to let us know if you
    want the parsing to start at the first or last incidence of each character.

    Do you need the Select statement to return the entire string? If not, then
    let us know what database type and version you are using so we can show you
    how to do it in your query.

    If you need both the entire string, and you need to parse it as well, then
    you will be better off doing it in vbscript in your asp page.
    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 31, 2004
    #2
    1. Advertising

  3. Lisa

    Lisa . Guest

    Bob,
    Yes that is an actual representative of my data. The only "variable"
    would be anything betweem "/" and ".". An actual example of my select
    results is: "Testing Documentation/Borland JBuilder 6.0 Validation
    Document.doc"

    My code looks like this:
    Dim strOldDocName, strIncremental, GetFileName, fullFileName
    strOldDocName = softwareManufacturer + " " + softwareProduct + " " +
    softwareVersion

    set OBJcmd = Server.CreateObject("Adodb.command")
    Set OBJcmd.ActiveConnection = oConn OBJcmd.CommandText = "SELECT * FROM
    DocMd WHERE URL LIKE '%" & strOldDocName & "%' ORDER BY URLID DESC;"
    Set rs = OBJcmd.execute

    fullfilename = rs.Fields("URL")- this is was generates the data
    mentioned above.

    strIncremental = FullFileName + "1"

    I need "strIncremental" to actually equal Parsed(FullFileName) + 1

    If NOT rs.EOF THEN
    GetFileName = strIncremental
    Else
    GetFileName = strOldDocName
    End If

    Lisa

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Lisa ., Aug 31, 2004
    #3
  4. Lisa . wrote:
    > Bob,
    > Yes that is an actual representative of my data. The only "variable"
    > would be anything betweem "/" and ".". An actual example of my select
    > results is: "Testing Documentation/Borland JBuilder 6.0 Validation
    > Document.doc"


    You see? There are two "."'s there. Will it always be the last "." that you
    want?

    >
    > My code looks like this:
    > Dim strOldDocName, strIncremental, GetFileName, fullFileName
    > strOldDocName = softwareManufacturer + " " + softwareProduct + " " +
    > softwareVersion
    >
    > set OBJcmd = Server.CreateObject("Adodb.command")
    > Set OBJcmd.ActiveConnection = oConn OBJcmd.CommandText = "SELECT *


    Don't be lazy. Avoid select * in production code:
    http://www.aspfaq.com/show.asp?id=2096

    > FROM DocMd WHERE URL LIKE '%" & strOldDocName & "%' ORDER BY URLID
    > DESC;" Set rs = OBJcmd.execute
    >
    > fullfilename = rs.Fields("URL")- this is was generates the data
    > mentioned above.


    Will you be doing anything else with fullfilename besides parsing it? Based
    on this code, the answer is no, but there may be code you haven't shown us

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 31, 2004
    #4
  5. Lisa

    Lisa . Guest

    You see? There are two "."'s there. Will it always be the last "." that
    you
    want?

    >>> I see your point. Yes I will always want the last "." in the string

    and that will be my only referrence to FullFileName.

    Lisa

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Lisa ., Aug 31, 2004
    #5
  6. Lisa . wrote:
    > You see? There are two "."'s there. Will it always be the last "."
    > that you
    > want?
    >
    >>>> I see your point. Yes I will always want the last "." in the string

    > and that will be my only referrence to FullFileName.
    >
    > Lisa
    >

    What database are you using? This can probably be done in your query.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 31, 2004
    #6
  7. Hotmail.

    Is it possible to check Hotmail email with an ASP?
     
    ca.yahoo@just1coder, Aug 31, 2004
    #7
  8. Lisa

    Lisa . Guest

    sorry I thought I posted my database info in my last message... I'm
    using SQL 7

    ~L~


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Lisa ., Aug 31, 2004
    #8
  9. Lisa . wrote:
    > sorry I thought I posted my database info in my last message... I'm
    > using SQL 7
    >
    > ~L~
    >
    >


    OK, here's a SQL 7+ solution (you should probably encapsulate this in a
    stored procedure rather than using dynamic sql):

    Dim sSQL
    sSQL = Select substring(REVERSE(Right(reverse(URL), " & _
    "len(URL) - charindex('.',REVERSE(URL)))),charindex('/',URL) " & _
    "+ 1,100) as filename FROM DocMd WHERE URL LIKE '%" & _
    strOldDocName & "%' ORDER BY URLID DESC;"
    'for debugging:
    'response.write sSQL
    Set rs=oConn.Execute(sSQL,,1)
    parsedFilename = rs("filename")

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 31, 2004
    #9
  10. Lisa

    Lisa . Guest

    Bob,
    I found what I was looking for....thought I would share, thanks!

    Dim strOldDocName, strIncremental, GetFileName, fullFileName
    strOldDocName = softwareManufacturer + " " + softwareProduct + " " +
    softwareVersion

    set OBJcmd = Server.CreateObject("Adodb.command")
    Set OBJcmd.ActiveConnection = oConn
    OBJcmd.CommandText = "MY SELECT STATEMENT;"
    Set rs = OBJcmd.execute

    fullFileName = rs.Fields("URL")
    Dim text, found, arrText, newDoc
    text = fullfilename
    arrText = Split(text,"/")
    For each item in arrText
    if InStr(item,".doc") > 0 then
    newDoc=replace(item,".doc","")
    end if
    next
    strIncremental = newDoc + "1"
    If NOT rs.EOF THEN
    GetFileName = strIncremental
    Else
    GetFileName = strOldDocName
    End If



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Lisa ., Aug 31, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GIMME
    Replies:
    2
    Views:
    918
    GIMME
    Feb 11, 2004
  2. Naren
    Replies:
    0
    Views:
    599
    Naren
    May 11, 2004
  3. Christopher Diggins
    Replies:
    0
    Views:
    624
    Christopher Diggins
    Jul 9, 2007
  4. Christopher Diggins
    Replies:
    0
    Views:
    454
    Christopher Diggins
    Jul 9, 2007
  5. John Levine
    Replies:
    0
    Views:
    756
    John Levine
    Feb 2, 2012
Loading...

Share This Page