Re: SP - output parameter not coming back
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 09:32:13 -0400
Axel wrote:
> Thanks Bob,
>
> lots of very interesting reading in all the links that you sent. A lot
> of the code I use is copy and paste so I will try and follow your
> advice on OLEDB vs ODBC and the one about not using objects in session
> variables, should be easy enough to change these. I also enabled SET
> NOCOUNT ON again, I had tested it with both options.
>
> I also added the return parameter to my command object (1st param
> added)
> CmdSP.Parameters.Append _
> CmdSP.CreateParameter("RETURN_VALUE", adInteger, _
> adParamReturnValue, 4)
> and I thought that this would actually solve my problem. but still I
> do not get anything useful back from @mycount.
>
> Also I have tested the SP using SQL Query Analyzer and it does not
> seem to set the output parameter. Looks like there is either
> something wrong in my SP Syntax or some underlying setting of the
> Server (is there a setting that disables output parameters - or maybe
> it has to do with the passed back recordset?)
If it does not work in query analyzer, it has no chance of working in asp
>
> I do not want to close the recordset because I want to display the
> number of results before the table of results. I also do not want to
> copy to a Array.
Not sure why you have an objection to this. See:
http://www.aspfaq.com/show.asp?id=2467
and
http://www.aspfaq.com/show.asp?id=2193
> The client side cursor did not help.
If it does not work in query analyzer, it has no chance of working in asp
>
> If I do not find out about the output parameter I am considering
> running 2 separate stored Procedures (1 to get the count of my query
> in a separate resultset, the other for the actual search results) but
> I know that this is a most unfortunate and expensive solution. At
> least this is only a product catalogue so the info in it is not highly
> volatile. However it might even be technically better than using a
> client side cursor - what do you think?
>
You definitely need to work on the stored procedure so that you can see the
result of the output parameter in query analyzer.
Oh wait! I just looked at your stored procedure. You're using dynamic sql in
your stored procedure?!? That is so wrong!
(http://www.sommarskog.se/dynamic_sql.html)
You don't even need it for your purpose! Get rid of it! Forget about this
Wherestring stuff! You are leaving yourself open to hackers using sql
injection attacks:
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23
http://www.nextgenss.com/papers/advanced_sql_injection.pdf
http://www.nextgenss.com/papers/more_advanced_sql_injection.pdf
http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf
Using exec(@sql) causes the sql statement to be executed in a different
scope. That is why your @mycount variable isn't getting populated. Read this
article for alternatives to dynamic sql:
http://www.sommarskog.se/dyn-search.html
There are several other good articles on that site so make sure you do some
browsing.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
.
- Follow-Ups:
- Re: SP - output parameter not coming back
- From: Axel
- Re: SP - output parameter not coming back
- References:
- Re: SP - output parameter not coming back
- From: Bob Barrows [MVP]
- Re: SP - output parameter not coming back
- From: Axel
- Re: SP - output parameter not coming back
- Prev by Date: Re: SP - output parameter not coming back
- Next by Date: Re: SP - output parameter not coming back
- Previous by thread: Re: SP - output parameter not coming back
- Next by thread: Re: SP - output parameter not coming back
- Index(es):
Relevant Pages
|