Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    11

    Unanswered: Help with strings and sql

    I m having a serious problem with the syntax for some string operations. What i want to do is, for example, to take a string from a text box that is a question, eg. "where is tower bridge", and i want to be able to recognise the part of the string 'where' in the question and compare the 'london bridge' with a list of sights in a db.

    for example in pseudo code:

    if question CONTAINS 'where is' and 'sights'

    reply = "'sight' is near 'tube station'

    can anyone help me with this dillema?
    many thanks in advance

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    I'm not very clear to your question, but I think that you can use the function

    InStr(string1, string2)

    to check if the string2 exists in string1.

  3. #3
    Join Date
    Mar 2004
    Posts
    11
    thanks for your reply, i was finding it hard to explain sorry!

    i have been working on this all day,

    ive got a question that is entered into a text box, eg. where is london bridge.

    and ive realised that using instr i can find out where london bridge is in the sentence, if i have:

    question = "where is london bridge"
    Response.Write InStr(question,"london bridge")

    but as you can see i have to know what the sight is to construct the statement, i want to have something like:

    question = "where is london bridge"
    Response.Write InStr(question,rs("sights"))

    where the question is compared against a list of sights in a database. but i dont know what the correct syntax is or if there is a better way of doing it.

  4. #4
    Join Date
    Dec 2003
    Posts
    454
    If I do not mis-understand your question, you want to know if the question entered by the user contains some words which are stored in database. For this case, you need a LOOP to find if the words is in the question.

    <%
    Do While Not theRS.EOF
    If InStr(question, RS("sights")) > 0 Then
    '*** do something here ***
    End If
    Loop
    %>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •