Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:02:17+00:00 2026-06-09T10:02:17+00:00

When I run the SQL through SQL Server 2008 it works just fine. However

  • 0

When I run the SQL through SQL Server 2008 it works just fine. However when I add it to a classic ASP web page and then call it from there it seems to break. I am not sure what I am missing?

sql = ""
sql = sql & " DECLARE @listStr VARCHAR(MAX)"

sql = sql & " DECLARE @temp TABLE ("
sql = sql & " DistID varchar(30),"
sql = sql & " FName varchar(30),"
sql = sql & " LName varchar(30),"
sql = sql & " RankID int, "
sql = sql & " PSV int,"
sql = sql & " ShipCountry varchar(30),"
sql = sql & " ShipState varchar(30) )"

sql = sql & " INSERT INTO @temp"
sql = sql & " EXEC  [dbo].[MSGGetList]"
sql = sql & " @List = N'" & request("report_type") & "',"
sql = sql & " @DistID = " & Session("DistributorID") & ","
sql = sql & " @BusCtrID = 1,"

' Autoship Filter Params
If request("autoship") <> "" Then
    sql = sql & " @FilterAutoship = '" & request("autoship") & "',"
Else
    sql = sql & " @FilterAutoship = NULL,"
End If

sql = sql & " @ItemID = " & request("item_id") & ","

' Order Filter Params
If request("orders") <> "" Then
    sql = sql & " @Orders = '" & request("orders") & "',"
Else
    sql = sql & " @Orders = NULL,"
End If

If request("minvol") <> "" Then
    sql = sql & " @MinVol = " & request("minvol") & ","
Else
    sql = sql & " @MinVol = NULL,"
End If

If request("minpostamt") <> "" Then
    sql = sql & " @MinPostAmt = " & request("minpostamt") & ","
Else
    sql = sql & " @MinPostAmt = NULL,"
End If

If request("startdate") <> "" Then
    sql = sql & " @DateStart = '" & request("startdate") & "',"
Else
    sql = sql & " @DateStart = NULL,"
End If

If request("enddate") <> "" Then
    sql = sql & " @DateEnd = '" & request("enddate") & "',"
Else
    sql = sql & " @DateEnd = NULL,"
End If

' Location Filter Params
If request("country") <> "" Then
    sql = sql & " @Country = '" & request("country") & "',"
Else
    sql = sql & " @Country = NULL,"
End If

If request("region") <> "" Then
    sql = sql & " @Region = '" & request("region") & "',"
Else
    sql = sql & " @Region = NULL,"
End If

' Rank Filter Params
If request("rankid") <> "" Then
    sql = sql & " @RankID = '" & request("rankid") & "',"
Else
    sql = sql & " @RankID = NULL,"
End If

'Do Not send list
If request("DoNotSend") <> "" Then
    sql = sql & " @Exempt = '" & request("DoNotSend") & "',"
End If

' Volume Filter Params
sql = sql & " @MinPV = " & request("min_pv") & ","
sql = sql & " @MaxPV = " & request("max_pv") & ","
sql = sql & " @MinGV = " & request("min_gv") & ","
sql = sql & " @MaxGV = " & request("max_gv") & ","
sql = sql & " @MinLBVRBV = NULL"
sql = sql & " SELECT @listStr = COALESCE(@listStr+',' ,'') + DistID FROM @temp"
sql = sql & " SELECT @listStr AS ToList"
stop
response.write(sql & "<br />")
Set rsToList = GetRecordSet(sql)


response.Write(rsToList("ToList"))

When I step through the code and look at rsToList it says:

Operation not allowed when object is closed

Any idea what I am missing here ?!

EDIT:

Function getRecordset(strSQL)

        If Application("DebugSQL") Then
            Call WriteSQL(strSQL)
        End If

        'Create Database Connection
        Set FunctionDBConn = Server.CreateObject("ADODB.Connection")
        FunctionDBConn.ConnectionTimeout = 180
        FunctionDBConn.Open(Application("DB_ConnectionString"))
        Set adoRS = Server.CreateObject("ADODB.Recordset")

        adoRS.CursorLocation = 3
        adoRS.LockType = 4

        'Create Recordset
        adoRS.Open strSQL, FunctionDBConn
        Set adoRS.ActiveConnection = Nothing
        Set GetRecordset = adoRS

        'Close Database Connection
        FunctionDBConn.Close
        Set FunctionDBConn = Nothing

    End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:02:18+00:00Added an answer on June 9, 2026 at 10:02 am

    The problem was the @temp Table. I added the functionality to the stored procedure and remove the temp table and it worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several Oracle queries that perform well when run through SQL*PLUS. However when
I want to run a diagnostic report on our SQL Server 2008 database server.
I'm running SQL Server 2008, and trying to run some queries on some poorly
I am using SQL Server 2008, and trying to run the following query in
Rails 3.1, Ruby 1.9.2, using a SQL Server 2008 database through the activerecord-sqlserver-adapter gem.
I have an SSIS package deployed to Sql Server 2008. This package runs fine
I'm trying to run following command on SQL Server 2008 DB sp_OACreate 'SQLXMLBulkLoad.SQLXMLBulkload', @object
Setup: IIS on Windows 2008 Server R2 Enterprise, SQL Server 2008 R2 Enterprise, ASP.NET
I'm using SQL Server 2008 and just recently started having an intermittent problem while
When I run SQL Server 2005 Database Tuning Advisor, it gives a recommendation to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.