I think you may be experiencing a discrepancy between empty strings and null values. An empty string does not have the same value as Null. On your results page, try doing a determination of the value it actually receives before trying to process it. You may find that your form is not sending the value you think it is.
<%
dim varTest
varTest = request.form("txtName")
Select Case varTest
Case NULL
response.write "I am NULL"
Case ""
response.write "I am an empty string"
Case else
response.write varTest
END SELECT
%> Weird ASP/SQL Problem Consider the following HTML Form, it has a textbox and a search button.
<form method=post action="search.asp"> <input name="txtName" type="text" id="txtEmail" /> <input type="submit" name="Submit3" value="Search" /> </form>The search.asp page:
select * from tbl_group_contact where userName ='"& request("txtName") &"'if I put this query in the search.asp page then it will search by name based on the name I entered in the textbox. But if I leave the textbox empty and click on the search button, SQL fetches all the rows from the table. If you havent noticed this before, try it now!! Well, this is not my problem/question. my question is if I place a combo box instead of the textbox and assign a NULL value to one of the option field like:
<select name="txtType" id="txtType"> <option value="" selected="selected">All</option> </select>and press the search button, then it does not fetch all the rows as it did for the empty textbox. Any idea why?