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
46 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
- Microsoft OLE DB Provider for SQL Server error '80040e0c' - Command text was not set for the command object 46
- Microsoft OLE DB Provider for SQL Server error '80040e14' Must declare the scalar variable 55
- asp.net cannot upload more than 25mb and will receive the error 404 - File or directory not found 58
- It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. 74
- ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl) 76
All Topics
- Coming Soon - Knowledge Exchange
Trending Articles
- Microsoft VBScript runtime error '800a0046' Permission denied FileSystemObject 23481
- 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. 20131
- ADODB.Parameters error '800a0e7c' Parameter object is improperly defined 18213
- After Effects warning: Audio conforming failed for the following file .cfa. Perhaps due to disk space 15947
- The backup set holds a backup of a database other than the existing 15629