SQL search in ASP

Results 1 to 2 of 2

Thread: SQL search in ASP

  1. #1
    John Greatrex Guest

    Default SQL search in ASP

    I am having trouble getting the correct SQL syntax to search a database using inputted text.<BR><BR>So far in ASP my SQL code is as follows:-<BR><BR>fnamevar = Request.Form("dbfname")<BR>SQLQuery = "SELECT * FROM webtest, wtgrade WHERE webtest.grade = <BR> wtgrade.grade AND webtest.fname like &#039" & fnamevar & "&#039"<BR>Set RSwebtest = OBJdbConnection.Execute(SQLQuery)<BR><BR>This works if I type in a text string that EXACTLY equals the database entry, but nothing else.<BR><BR>How can I make my search more flexible?<BR><BR>john.greatrex@dfee.gov.uk

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL search in ASP

    First things first is debug.<BR><BR>Test that there are no spaces at the end or beginning of fnamevar (I usually do Trim(varname) before I submit it)<BR><BR>Then check that it is in the correct case, a work around for that is:-<BR><BR>"SELECT * FROM webtest, wtgrade WHERE webtest.grade = <BR>wtgrade.grade AND Upper(webtest.fname) like &#039" & ucase(fnamevar) & "&#039"<BR><BR><BR>

Posting Permissions

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