Ifrequest.querystring="One"then
strSQL = "Select ColOne from TableOne where ColTwo=?"elseifrequest.querystring="Two"thengetSQL = "Select ColOne from TableTwo where ColTwo=?"end if
The above IF THEN Statement is accurate. If the QueryString equals ONE We give the user the database from that Query. However, in the ELSEIF Statement, the Variable is misspelled, so when the user requests two in the QueryString, they will receive an error.
Microsoft OLE DB Provider for SQL Server error '80040e0c.' Command text was not set for the command object /Results.asp, line 133
Resolve Issue
As demonstrated above, we have to ensure our Variables in all Queries are spelled correctly for our Database Queries to work.
Ifrequest.querystring="One"then
strSQL = "Select ColOne from TableOne where ColTwo=?"elseifrequest.querystring="Two"then
strSQL = "Select ColOne from TableTwo where ColTwo=?"end if
Now, with both Variables being the same name, strSQL. We can now run our database query to retrieve the requested results.