Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 1st, 2004, 05:00 AM
e2rd e2rd is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 e2rd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Stored Procedure Return value

Dear all, please help again.
I create stored procedure like this:
-----------------
CREATE PROCEDURE sp_test AS
select * from employee
GO
-----------------

and when I call from ASP:
rsconn.recordcount
its return--> 2546

But why if I create stored procedure like this:
-----------------------
CREATE PROCEDURE sp_test AS
DECLARE @result TABLE(apl_group varchar(2), total float, aver float, grade int, account int)
.... some code....
select * from @result
GO
-------------------------
Its always return---> -1

How to solved this problem?
Please help me.

Regards,


e2rd

Reply With Quote
  #2  
Old July 1st, 2004, 01:35 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
recordcount will fail in many cases. Look at the ADO recordset documentation, MS has a fairly detailed explanation of how and when recordcount may not work.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old July 2nd, 2004, 02:19 AM
Tonny-Soeroso Tonny-Soeroso is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 36 Tonny-Soeroso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 56 m 27 sec
Reputation Power: 0
Smile

E2rd,
Recordcount return -1 means that the number of records contained can't be determined.
bisa liat contoh sp kamu?


Regards

Tonny

Reply With Quote
  #4  
Old July 13th, 2004, 04:53 AM
e2rd e2rd is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 e2rd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face

Dear pak Tonny Soeroso,
Here is my sp example.

regards,

e2rd


CREATE PROCEDURE sp_r_sales_structure
AS
DECLARE @table TABLE(REGION VARCHAR(30), NPK_DIAMOND VARCHAR(10), NAMA_DIAMOND NVARCHAR(255),
NPK_GOLD VARCHAR(10), UPLINE_GOLD VARCHAR(10), NAMA_GOLD NVARCHAR(255),
NPK_SILVER VARCHAR(10), UPLINE_SILVER VARCHAR(10), NAMA_SILVER NVARCHAR(255)
)
DECLARE @REGION VARCHAR(30), @NPK_DIAMOND VARCHAR(10), @NAMA_DIAMOND NVARCHAR(255),
@NPK_GOLD VARCHAR(10), @UPLINE_GOLD VARCHAR(10), @NAMA_GOLD NVARCHAR(255),
@NPK_SILVER VARCHAR(10), @UPLINE_SILVER VARCHAR(10), @NAMA_SILVER NVARCHAR(255)
DECLARE edo_cursor CURSOR FOR
SELECT b.region, e.npk as NPK_DIAMOND, e.nama as NAMA_DIAMOND,
e1.npk as NPK_GOLD, e1.upline AS UPLINE_GOLD, e1.nama AS NAMA_GOLD,
e2.npk AS NPK_SILVER, e2.upline AS UPLINE_SILVER, e2.nama AS NAMA_SILVER
FROM employee e
INNER JOIN employee e1 ON e.npk=e1.upline AND e1.sales_level='02'
INNER JOIN employee e2 ON (e1.npk=e2.upline OR e.npk=e2.upline) AND e2.sales_level='03'
INNER JOIN branch b ON b.rc=e.branch_code
WHERE e.sales_level='01'
ORDER BY NPK_DIAMOND, UPLINE_GOLD, UPLINE_SILVER

OPEN edo_cursor
FETCH NEXT FROM edo_cursor INTO @REGION, @NPK_DIAMOND,@NAMA_DIAMOND, @NPK_GOLD, @UPLINE_GOLD, @NAMA_GOLD, @NPK_SILVER, @UPLINE_SILVER, @NAMA_SILVER
WHILE @@FETCH_STATUS = 0
BEGIN
IF @UPLINE_SILVER = @UPLINE_GOLD
BEGIN
SET @NPK_GOLD=@NPK_DIAMOND
SET @NAMA_GOLD=@NAMA_DIAMOND
END
INSERT @table VALUES (@REGION, @NPK_DIAMOND,@NAMA_DIAMOND, @NPK_GOLD, @UPLINE_GOLD, @NAMA_GOLD, @NPK_SILVER, @UPLINE_SILVER, @NAMA_SILVER)
FETCH NEXT FROM edo_cursor INTO @REGION, @NPK_DIAMOND,@NAMA_DIAMOND, @NPK_GOLD, @UPLINE_GOLD, @NAMA_GOLD, @NPK_SILVER, @UPLINE_SILVER, @NAMA_SILVER
END

CLOSE edo_cursor
DEALLOCATE edo_cursor
select distinct * from @table

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Stored Procedure Return value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT