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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Command text was not set for the command object.

Status
Not open for further replies.

TonyRosen

Programmer
Jul 28, 2003
108
US
I am simply inserting some form data in an SQL database. Every other page within the application works except for this one. I've moved my connection string around and still receive the error:

"Command text was not set for the command object."

Which is hokey, because it is ... as far as I can tell.

Basically, what I have:
*******
'Connection String is here

'Retrieve various form data

'server-side validate the data
ValidateForm = true
if len(firstname) = 0 then
ValidateForm = false
end if
'And so forth down the fields

'check to see if data might already exist
'This is where I receive the error.
strSQL = "SELECT lastname FROM db_name where lastname = '" & strlastname & "'"
Set objRS = objConn.Execute(strSQL)

If objRS.EOF Or objRS.BOF Then
'It doesn't exist
Else
'It does
End If

'Closing all my stuff down here
********************

Now, what is my server finding wrong with that?

Thanks!
 
how are you setting the lock and cursor type when p[ening the connection?

can you post the actual INSERT also. Are you using commands?

relavent code that would help to see is
the recordset create
the connection create

the connection open line

the SQL for the INSERT

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
My Code:

*****************************
Set objconn = Server.CreateObject("ADODB.Connection")
objconn.open "Driver={SQL Server};Server=ServerName;Database=MyDB;Uid=MyUsername;Pwd=MyPassword;"

'Let's assume that:
strlastname = "Rosen"

strSQL = "SELECT lastname FROM table_name where lastname = '" & strlastname & "'"
Set objRS = objConn.Execute(strSQL)

********************
Then, I get my error ... before the insert ... WELL before the insert. I get it on the SELECT statement.
 
The error which you are getting is not related to your SQL query or the database connections.

You have to check whether all your cursor and lock types are set properly or not.

Did you include the adovbs.inc file..
something like this:
<!-- #include file="adovbs.inc" -->


-VJ
 
AHA!

Moved my connection string to within my "If-Else" statement (after the form validation) and it worked like a champ.

Apparently, it had an issue with connecting, then validating, then getting my recordset.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top