• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 754
  • Last Modified:

Command text was not set for the command object.

Help I'm getting the following error -

Command text was not set for the command object. - Line Number: 131

Where Line number 131 is -

Set RSChildLinks = RSChildLinks_cmd.Execute

Open in new window


From  -

<%
IF Request.ServerVariables("QUERY_STRING") <> "" THEN
Dim RSChildLinks__MMColParam
RSChildLinks__MMColParam = NULL
If (Request("ID") <> "") Then 
  RSChildLinks__MMColParam = Request("ID")
End If

Dim RSChildLinks
Dim RSChildLinks_cmd
Dim RSChildLinks_numRows

Set RSChildLinks_cmd = Server.CreateObject ("ADODB.Command")
RSChildLinks_cmd.ActiveConnection = MM_GolfConnection_STRING

If Session("UKMember") = "Y" then
If Session("Shareholder") = "N" THEN
RSChildLinks_cmd.CommandText = "Select ID, Title, SEOLink From dbo.MyPage Where ParentID = (Select ID from dbo.MyPage WHERE ID = ? AND PageType NOT IN(2,3)) AND Live = 'Y' AND Hidden = 'N' AND UK = 'Y' AND ShareholderOnly <> 'Y' Order By Title" 
RSChildLinks_cmd.Prepared = true
RSChildLinks_cmd.Parameters.Append RSChildLinks_cmd.CreateParameter("param1", 5, 1, -1, RSChildLinks__MMColParam) ' adDouble
ELSEIf Session("Shareholder") = "Y" THEN
RSChildLinks_cmd.CommandText = "Select ID, Title, SEOLink From dbo.MyPage Where ParentID = (Select ID from dbo.MyPage WHERE ID = ? AND PageType NOT IN(2,3)) AND Live = 'Y' AND Hidden = 'N' AND UK = 'Y' Order By Title" 
RSChildLinks_cmd.Prepared = true
RSChildLinks_cmd.Parameters.Append RSChildLinks_cmd.CreateParameter("param1", 5, 1, -1, RSChildLinks__MMColParam) ' adDouble
END IF
ElseIf Session("EireMember") = "Y" then
If Session("Shareholder") = "N" THEN
RSChildLinks_cmd.CommandText = "Select ID, Title, SEOLink From dbo.MyPage Where ParentID = (Select ID from dbo.MyPage WHERE ID = ? AND PageType NOT IN(2,3)) AND Live = 'Y' AND Hidden = 'N' AND Eire = 'Y' AND ShareholderOnly <> 'Y' Order By Title" 
RSChildLinks_cmd.Prepared = true
RSChildLinks_cmd.Parameters.Append RSChildLinks_cmd.CreateParameter("param1", 5, 1, -1, RSChildLinks__MMColParam) ' adDouble
ELSEIf Session("Shareholder") = "Y" THEN
RSChildLinks_cmd.CommandText = "Select ID, Title, SEOLink From dbo.MyPage Where ParentID = (Select ID from dbo.MyPage WHERE ID = ? AND PageType NOT IN(2,3)) AND Live = 'Y' AND Hidden = 'N' AND Eire = 'Y' Order By Title" 
RSChildLinks_cmd.Prepared = true
RSChildLinks_cmd.Parameters.Append RSChildLinks_cmd.CreateParameter("param1", 5, 1, -1, RSChildLinks__MMColParam) ' adDouble
END IF
ElseIf Session("EUMember") = "Y" then
If Session("Shareholder") = "N" THEN
RSChildLinks_cmd.CommandText = "Select ID, Title, SEOLink From dbo.MyPage Where ParentID = (Select ID from dbo.MyPage WHERE ID = ? AND PageType NOT IN(2,3)) AND Live = 'Y' AND Hidden = 'N' AND EU = 'Y' AND ShareholderOnly <> 'Y' Order By Title" 
RSChildLinks_cmd.Prepared = true
RSChildLinks_cmd.Parameters.Append RSChildLinks_cmd.CreateParameter("param1", 5, 1, -1, RSChildLinks__MMColParam) ' adDouble
ELSEIf Session("Shareholder") = "Y" THEN
RSChildLinks_cmd.CommandText = "Select ID, Title, SEOLink From dbo.MyPage Where ParentID = (Select ID from dbo.MyPage WHERE ID = ? AND PageType NOT IN(2,3)) AND Live = 'Y' AND Hidden = 'N' AND EU = 'Y' Order By Title" 
RSChildLinks_cmd.Prepared = true
RSChildLinks_cmd.Parameters.Append RSChildLinks_cmd.CreateParameter("param1", 5, 1, -1, RSChildLinks__MMColParam) ' adDouble
End If
End If

Set RSChildLinks = RSChildLinks_cmd.Execute
RSChildLinks_numRows = 0
End If
%>

Open in new window


Any suggestions please?

Thank you
0
garethtnash
Asked:
garethtnash
  • 3
  • 3
2 Solutions
 
Scott Fell, EE MVEDeveloperCommented:
You have

If Session("UKMember") = "Y" then
If Session("Shareholder") = "N" THEN


It looks like if those are not set you will get your error.  Try putting If Session("UKMember") = "Y" then above the code and don't for get to move the end if.    

Just before the line where you get the error do a response.write RSChildLinks_cmd to see what is happening.  Also, for each of your if statements, do a response.write just to double check if those are blocking anything.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this means that at least one of the if/else ... combinations allow the code to not set the command text.
you can double-check the commandtext value before running the .execute method...

I think it's because you have if/elseif but no final else to cover the cases when the values are neither 'Y' nor 'N'
0
 
garethtnashAuthor Commented:
Hi All,

This is really strange, the site works fine in IE9, but fails in FF or Chrome, now I'm getting -

ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
/includes/Bulletin.asp, line 34

My Code is --

<%

Dim Bulletin_cmd__UKMember
Bulletin_cmd__UKMember = "N"
if(Session("UKMember") <> "") then Bulletin_cmd__UKMember = Session("UKMember")

Dim Bulletin_cmd__EireMember
Bulletin_cmd__EireMember = "N"
if(Session("EireMember") <> "") then Bulletin_cmd__EireMember = Session("EireMember")

Dim Bulletin_cmd__EUMember
Bulletin_cmd__EUMember = "N"
if(Session("EUMember") <> "") then Bulletin_cmd__EUMember = Session("EUMember")

Dim Bulletin_cmd__Shareholder
Bulletin_cmd__Shareholder = "N"
if(Session("Shareholder") <> "") then Bulletin_cmd__Shareholder = Session("Shareholder")

set Bulletin_cmd = Server.CreateObject("ADODB.Command")
Bulletin_cmd.ActiveConnection = MM_GolfConnection_STRING
Bulletin_cmd.CommandText = "dbo.ListBulletinsSmall2"
Bulletin_cmd.CommandType = 4
Bulletin_cmd.CommandTimeout = 0
Bulletin_cmd.Prepared = true
Bulletin_cmd.Parameters.Append Bulletin_cmd.CreateParameter("@RETURN_VALUE", 3, 4)
Bulletin_cmd.Parameters.Append Bulletin_cmd.CreateParameter("@UKMember", 129, 1,1,Bulletin_cmd__UKMember)
Bulletin_cmd.Parameters.Append Bulletin_cmd.CreateParameter("@EireMember", 129, 1,1,Bulletin_cmd__EireMember)
Bulletin_cmd.Parameters.Append Bulletin_cmd.CreateParameter("@EUMember", 129, 1,1,Bulletin_cmd__EUMember)
Bulletin_cmd.Parameters.Append Bulletin_cmd.CreateParameter("@Shareholder", 129, 1,1,Bulletin_cmd__Shareholder)
set RsBulletin = Bulletin_cmd.Execute
Bulletin_numRows = 0

dim arrBulletin
arrBulletin = RsBulletin.GetRows()

RsBulletin.Close()
Set RsBulletin = Nothing
Set Bulletin_cmd = Nothing
%>

Open in new window


My Stored Procedure is -

CREATE PROCEDURE [dbo].[ListBulletinsSmall2]
(
@UKMember char(1)= 'N',
@EireMember char(1)= 'N',
@EUMember char(1)= 'N',
@Shareholder char(1)= 'N'
)
AS
SET NOCOUNT ON;
BEGIN
IF @UKMember = 'Y'
BEGIN
IF @Shareholder = 'N'
BEGIN
SELECT TOP(3) ID, Left(Title,35)+ '..' Title, Left(Content,108) +'....' Content, SEOLink FROM dbo.MyPage  WHERE ParentID = 5 AND UK = 'Y' AND Live = 'Y' AND ShareholderOnly <> 'Y' ORDER BY DatePublished DESC
END
ELSE IF @Shareholder = 'Y'
BEGIN
SELECT TOP(3) ID, Left(Title,35)+ '..' Title, Left(Content,108) +'....' Content, SEOLink  FROM dbo.MyPage  WHERE ParentID = 5 AND UK = 'Y' AND Live = 'Y' ORDER BY DatePublished DESC
END
END

IF @EireMember = 'Y'
BEGIN
IF @Shareholder = 'N'
BEGIN
SELECT TOP(3) ID, Left(Title,35)+ '..' Title, Left(Content,108) +'....' Content, SEOLink  FROM dbo.MyPage  WHERE ParentID = 5 AND Eire = 'Y' AND Live = 'Y'AND ShareholderOnly <> 'Y'  ORDER BY DatePublished DESC
END
ELSE IF @Shareholder = 'Y'
BEGIN
SELECT TOP(3) ID, Left(Title,35)+ '..' Title, Left(Content,108) +'....' Content, SEOLink  FROM dbo.MyPage  WHERE ParentID = 5 AND Eire = 'Y' AND Live = 'Y' ORDER BY DatePublished DESC
END
END

IF @EUMember = 'Y'
BEGIN
IF @Shareholder = 'N'
BEGIN
SELECT TOP(3) ID, Left(Title,35)+ '..' Title, Left(Content,108) +'....' Content, SEOLink FROM dbo.MyPage  WHERE ParentID = 5 AND EU = 'Y' AND Live = 'Y'AND ShareholderOnly <> 'Y'  ORDER BY DatePublished DESC
END
ELSE IF @Shareholder = 'Y'
BEGIN
SELECT TOP(3) ID, Left(Title,35)+ '..' Title, Left(Content,108) +'....' Content, SEOLink FROM dbo.MyPage  WHERE ParentID = 5 AND EU = 'Y' AND Live = 'Y' ORDER BY DatePublished DESC
END
END
END


GO

Open in new window


Is this perhaps a session issue in FF Chrome? - thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Scott Fell, EE MVEDeveloperCommented:
I wonder if you are actually getting the error in ei but it shows the partial page.  What happens if you view source? Can you see an error at the bottom?  You have a server side error so the browser should not make a difference.  

You need to trouble shoot all of your if then statements.  Did you work on the first issue you stated yet?
0
 
garethtnashAuthor Commented:
I've managed to find the bit of code that has been causing the issue --

<base href="http://www.testmy.domain.com" />

Not sure why though? It was basically killing the Session Variables after the page had been written?

Deleted it, no probl;ems now...

Any thoughts?

Thanks
0
 
Scott Fell, EE MVEDeveloperCommented:
If you set your session variables on www.domain.com then moved to a page on the subdomain www.testmy.domain.com then you are on a new session.  

I'm glad you found your problem.
0
 
garethtnashAuthor Commented:
Thanks Both
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now