KB Issue
The error "Command text was not set for the command object" means that the Commandtext is not applied to the statement.
Issue Details
If we look at this Statement, we have a good source for our Commandtext.
searchsql.commandtext="Select ColOne from TableOne where ColTwo=?"
Copy
Search Site
Search Google

However, if we use another method in place of our Statement, like this.
searchsql.commandtext=strSQL
Copy
Search Site
Search Google

And if the Variable is not found or cannot be read, then we will receive the error.
Microsoft OLE DB Provider for SQL Server error '80040e0c.'
"Command text was not set for the command object."
Recreate Issue
In the code below, we are making different calls using QueryStrings to determine the Database call we need for each Query.
[Classic ASP - IS ELSE Statement]
CFFCS | CarrzSynEdit: | ASP/VBScript
If request.querystring="One" then
strSQL = "Select ColOne from TableOne where ColTwo=?"
elseif request.querystring="Two" then
getSQL = "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.
[Classic ASP - IF ELSE Statement]
CFFCS | CarrzSynEdit: | ASP/VBScript
If request.querystring="One" then
strSQL = "Select ColOne from TableOne where ColTwo=?"
elseif request.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.
[Classic ASP - Parameterized Queries]
CFFCS | CarrzSynEdit: | ASP/VBScript
Set searchsql = Server.CreateObject("ADODB.Command")
searchsql.ActiveConnection=siteconn
searchsql.Prepared = true
searchsql.commandtext=strSQL
set rssearchsql = searchsql.execute