Command text was not set for the command object

Error "Command text was not set for the command object" occurs in Set oRS = conn.Execute(strSQL) .  Please help.  thanks.            



<%
function conn(strSQL)
      'Create and open the database connection object
      Set conn = Server.CreateObject("ADODB.Connection")
      conn.Open application("connstr"),"user","password"
      
      startStmt = Mid(trim(strSQL),1,6)
      page_id = Request.QueryString("page")
      if page_id = "" then
            page_id = Request.QueryString("page_id")
      end if
      
            auditSQL = "INSERT INTO ......"
            auditSQL = replace(auditSQL,"''''","''")
            session("strSQL") = auditSQL
            Set oRS = conn.Execute(auditSQL)

      'Executing query
      session("strSQL") = strSQL
      Set oRS = conn.Execute(strSQL)
      Set conn = oRS

      Set oRS = Nothing
end function

%>
ewang1205Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VAScottCommented:
where is session("strSQL") getting set?  sounds like strSQL is not getting set correctly.
try adding a write just before that line and see what (if any) SQL statement gets output, like this:

response.write(strSQL)
Set oRS = conn.Execute(strSQL)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevp75Commented:
just for testing, you may want to do this as well.

response.write Application("connstr")

at the top of your code, just to make sure the connection string is being set in your global.asa file
Anthony PerkinsCommented:
An INSERT statement never returns a resultset.  You need to lose the Set oRS, as in:

<%
function conn(strSQL)
     'Create and open the database connection object
     Set conn = Server.CreateObject("ADODB.Connection")
     conn.Open application("connstr"),"user","password"
     
     startStmt = Mid(trim(strSQL),1,6)
     page_id = Request.QueryString("page")
     if page_id = "" then
          page_id = Request.QueryString("page_id")
     end if
     
     auditSQL = "INSERT INTO ......"
     auditSQL = replace(auditSQL,"''''","''")
     session("strSQL") = auditSQL
     conn.Execute auditSQL

     'Executing query
     session("strSQL") = strSQL
     conn.Execute strSQL
     conn.Close
     Set conn = Nothing

end function

%>
Anthony PerkinsCommented:
And of course, I am making the assumption that strSQL is not a SELECT statement.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.