CFF KB - Carrz-Fox-Fire Promotions Knowledge Base
CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.Knowledge Base
- Breadrumbs:
Microsoft OLE DB Provider for SQL Server error '80040e0c' - Command text was not set for the command object
- Article ID:
6265 - Date Created
Tuesday, February 14, 2023 - Last Updated
Tuesday, February 14, 2023 - This Article Has been Viewed
872 times - Short Desc
The error "Command text was not set for the command object" means that the Commandtext is not applied to the statement. - Details
If we look at this Statement, we have a good source for our Commandtext.<%
searchsql.commandtext="Select ColOne from TableOne where ColTwo=?"
%>
However, if we use another method in place of our Statement, like this.<%
searchsql.commandtext=strSQL
%>
And if the Variable is not found or able to be read, then we will receive the error.
"Command text was not set for the command object." - Recreate Issue
In the below code, we are making different calls using QueryStrings to determine the Database call we need for each Query.
Example<%
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 in the way it works.
If the QueryString equals ONE
We give the user the database from that Query.
However, in the ELSEIF Statement, the Variable is incorrectly spelled, so when the user request Two in the QueryString, they will receive the 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.<%
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 get the results requested.<%
Set searchsql = Server.CreateObject("ADODB.Command")
searchsql.ActiveConnection=siteconn
searchsql.Prepared = true
searchsql.commandtext=strSQL
set rssearchsql = searchsql.execute
%>
Share With Friends (Updated 6-8-2010)
Recent Articles
All Topics
- Coming Soon - Knowledge Exchange
Trending Articles
- Microsoft VBScript runtime error '800a0046' Permission denied FileSystemObject 24695
- Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. 21297
- ADODB.Parameters error '800a0e7c' Parameter object is improperly defined 19544
- After Effects warning: Audio conforming failed for the following file .cfa. Perhaps due to disk space 17785
- The backup set holds a backup of a database other than the existing 16825