Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command text was not set for the command object 1

Status
Not open for further replies.

gc1234

Programmer
Mar 4, 2004
94
GB
Hi

I have had a working site for a while, now I ge this error?

"Command text was not set for the command object"

what is actually required?

my code

set connTemp=server.createobject("adodb.connection")
set rs=server.createobject("adodb.RecordSet")
connstring = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" &server.MapPath("pteng.mdb")&";"
connTemp.Open connstring


set rs = conntemp.Execute(mySql) 'error here
 
Your string MySQL could be having problems with the way it has been constructed.

rsshetty.

It's always in the details.
 
Try being more specific in the Execute method and force it to treat that string as a statement. I think that error usually means the object is confused and doesn't realize whether it is opening a table name, a query, or a stored proc.

Look here for more info on the Execute method. I think if you change that to set rs = conntemp.Execute(mySql,,1) you may fix the error. I know i have run into this once before, but the details are hazy.

Also, just a note, you don't need to instantiate a recordset object if your going to be using the connection to execute a query nd return a recordset. Any time you use the "Set" keyword it overwrites object reference that was originally in your variable, meaning tht any object that was there is no longer. So you can leave out:
Set rs = Server.CreateObject("ADODB.RecordSet")

technically you could probably even set that variable to whateve you want ad after the recordset it would be referencing the resulting recordset anyways. So you could:
Set rs = Server.CreateObject("Scripting.FileSystemObject")

which would instantiate a file system object and assign a reference to the variable. Then your later set would change that reference to the incoming recordset. I'm not 100% sure VBScript would like this, but that is the way it is setup to work.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Correct folks, mySql was not valid, really is still a none informative error message dont you think?
 
Your problem is that your mySql variable is empty ie has not been initialized with a valid sql statement.
To see what it contains do the following:
Write these lines :
Response.Write mySQL &" this is the query"
Response.end

just before this one
set rs = conntemp.Execute(mySql) 'error here:

Bertrandkis


 
I know, thxs, still, not an informative error message, whats up with, "string is empty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top