Re: object closed error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



As you can see, I get the destination DB on runtime.
I know that the product that I am looking for exists and I do get the row
when I execute it with Query Analyzer.
But, on the next line in my code, when I check the record count, I get an
object closed error.

Thanks,
Elizabeth

CREATE PROCEDURE [sp_mandat_dest_comp]
@dest_comp varchar(20),
@product_code varchar(4)
AS

Declare @stmt nvarchar(1000)
Declare @params nvarchar(1000)

Set
@stmt = N'Select product_code From ['
+ @dest_comp
+ N'].dbo.pr_products '
+ N'Where product_code = '
+ N'@product_code'

Set
@params = N'@dest_comp varchar(20), '
+ N'@product_code varchar(4)'

Print @stmt

Execute sp_executesql
@stmt,
@params = @params,
@dest_comp = @dest_comp,
@product_code = @product_code
GO

--
Elizabeth


"Veign" wrote:

> Post some code, post your SQL statements and point to the line causing the
> error.
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
>
>
> "Elizabeth" <Elizabeth@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:69FFC8B6-C81E-47E2-9F5D-4EB624FB3B06@xxxxxxxxxxxxxxxx
> > Hi there,
> > I am trying to execute an SQL statement but get an object closed error.
> > It's a valid SQL and works fine in Query Analyzer.
> > I found some discussion about this issue but couldn't find any
> conclusions.
> >
> > Any help is appreciated,
> > --
> > Elizabeth
>
>
>
.



Relevant Pages