Mr. Fuller,
Thank you for your many useful submissions to this forum. I have been able to make good use of them. In this one, however, you made a mistake that I feel deserves attention. (By the way, thanks for the obvious correction posts to the text.) In the article, you write that
"Porting such an approach to SQL Server is bad for several reasons: "
and state that one is:
"This approach is subject to SQL injection attacks."
This is true. But the very solution you propose does the same, without even having to have the intent. One simply has to hit the submit button (or some such option) without having placed a value in the control. All order data would be returned, just as you state. I think you would agree that this is not exactly a secure application.
A more proper way of handling this would be to use an "AND" addtion to the SQL Statement, since you write that this was the intent of the original Access program. That is:
SELECT *
FROM SomeTables
WHERE ColumnOfInterest = myParameter AND myParameter is NOT NULL
**OR**
SELECT *
FROM SomeTables
WHERE ColumnOfInterest = myParameter AND ColumnOfInterest is NOT NULL
This would require that the entry be one that the user would have to know. Further security, such as looking at signon info, would probably work with either your or my suggested solution. I realize in the specific example you gave later, only the order date is in question, indicating that some such further security is in place. My suggestion is simply generic. You could use it in the same way that earlier articles have suggested for the prevention of SQL Injection, to keep intentional or unintentional pulling of non-related data.
Thanks, again, for your articles.