Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2003
    Location
    Hong Kong
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Use Dictionary Object or Database?

    Hi,

    I need to build a web-based application (ASP) that is similar to a dictionary. A user types in many words (range from 1 to serveral hundreds) and then I need to find out (one by one) whether these words exit in my database.

    The words are already stored in SQL Server and my question is whether I should:

    1. use a SQL statement to retrieve the words one by one (eg. a 300-word input means 300 querys)

    2. use a dictionary object to first retrieve all the words from SQL server and then the user query the dictionary object

    I have never used the dictionary object and hence don't know whether it is a good option in my case.

    Thanks.
    Michael

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post
    sorry i dont have the one stop answer fo ryou, but I would like to know why you are allowing the user to send a 300 word query to your site/db??

    Is that necessary? I mean, wouldn't like 1 or 2 words be sufficient. and if they need more type those after they have received the results for the first search?

    -------------

    this is just theory, but let's say you have the user make their 300 word query.
    you could split that into an array, then use a sub/function to build a query based on the ubound of the array and the values in it.

    example...
    Code:
    For i = 0 to UBound(aList)
      If i = UBound(aList) Then
        qry = qry & "word=""" & aList(i) & """"
      Else
        qry = qry & "word=""" & aList(i) & """ OR "
      End If
    Next
    qry = "SELECT * FROM table WHERE " & qry
    I dont even know if this would work. its not tested i just drafted it up at time of posting.

    i don tknow. i was just throwing out an idea. could you tell more about this dictionary thing you're making. I dont quite get what its for. or doing.
    anthony

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    Code:
    StrInput = "words|separated|by|a|delimiter"
    ArrInput = Split(StrInput, "|")
    SQLString = "SELECT * FROM TableName WHERE Word IN ('" & Join(ArrInput, "' , '") & "')"
    (Note that there are single and double quotes in there, and that the delimiter could just as easily be a space)

    I'm sure you can figure out how to use it!
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"


  •  

    Posting Permissions

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