Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Stored Procedure maybe?

Status
Not open for further replies.

sonya9879

Programmer
Jun 18, 2004
147
CA
I have a procedure that give me results when I run it on EM but it doesn't when I run it on ASP.NET.

CREATE PROCEDURE testproc
(
@ID int,
@TEL int,
@RES int OUTPUT,
@RESD varchar(20) OUTPUT
)
AS
SELECT
a.RES,
a.RESD
FROM vTTM a LEFT OUTER JOIN
(SELECT tab2.id
FROM tab2 INNER JOIN
tab9 ON tab2.id = tab9.t2_id
WHERE tab2.ID=@ID
AND tab2.TEL= @TEL
GROUP BY tab2.id) b ON a.idt = b.id
GO

I wanted to add this to the SELECT:

SELECT
@RES = a.RES,
@RESD = a.RESD

ERROR: A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations

then I tried to hardcore the results just to see if I could see my values in my ASP.NET application,

SELECT
@RES = 1,
@RESD = 'TEST'

diddn't work, got the same result.

Again, the procedure works fine if I run it via EM

exec testproc 1,22,0,0 that give the the correct results and RES and RESD have the appropiate result values I want.

I am lost, I tried to post this in the ASP.NET forum just in case I had something wrong on my code. Perhaps is my stored procedure... ???? any thoughts?

thanks so much
 
ok ignore all of this and sorry to bother all, I found the problem thanks god :).
I needed to instantiate the variables for both results:

(
@ID int,
@TEL int,
@RES int OUTPUT,
@RESD varchar(20) OUTPUT
)
AS
SELECT
@RES = a.RES,
@RESD = a.RESD
FROM vTTM a LEFT OUTER JOIN
(SELECT tab2.id
FROM tab2 INNER JOIN
tab9 ON tab2.id = tab9.t2_id
WHERE tab2.ID=@ID
AND tab2.TEL= @TEL
GROUP BY tab2.id) b ON a.idt = b.id
GO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top