Results 1 to 2 of 2

Thread: SQL

  1. #1
    Join Date
    Dec 1969

    Default SQL

    Hi, I have a form in which one can search for employees in our company. The form contains of several textboxes and lists. Such as Name, date of birth, employeenumber, which group in the company you belong to etc. I want the user to be able to search in as many categories he wants to. Maybe just the name, or all people in a group, or all persons that were born 1950 and are located in a specific city....I think you see what I mean. Now to my question. How do I create a SQL that manage to search in the database no matter how many criterias there are. It can't be necessary to make different SQLs depending on which criterias the user is choosing. Could you help me please. /Charlotte

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL

    One way to do this is to build your SQL query dynamically in whatever language you&#039;re using. The code would include a bunch of conditional statements that append where clauses to the SQL statement as necessary. Here&#039;s a skeleton of how it might work:<BR><BR>strSQL = "SELECT something FROM somewhere WHERE "<BR><BR>if somecondition then<BR> strSQL = strSQL & somecondition<BR>end if<BR><BR>...<BR><BR>if someothercondition then<BR> strSQL = strSQL & someothercondition<BR>end if<BR><BR>recordset.open strSQL, connection<BR><BR>The code could be quite long, but it would give you the flexibility you need.<BR><BR>Marios Alexandrou<BR>Web and Desktop Software Developer<BR>http://www.mariosalexandrou.com

Posting Permissions

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