473,396 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

return values and recordset in one stored procedure

2
Hi

We have an application that runs fine on SQL 2000. Due to other applications we are forced to move to SQL 2005.

One Stored Procedure isn't working on the new SQL 2005. It's a SP with output parameters and a recordset. It's working fine on SQL 2000.

The data is returned through OLEDB to a VB6 application. In this application the output parameters are working fine (can access them). But the recordset isn't working. Both EOF en BOF are true...

Executing the SP from SQL Server Management Studio works fine.

Is it not allow to have output parameters and a recordset anymore? Or is the code different?

I hope you can help...


Below is the SP and the VB6 code:

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[ADM_LS_SelectUserPassword]
  2.   @UserName   varchar(16),
  3.   @UserID  int  OUTPUT,
  4.   @UserPassword  varchar(16) OUTPUT,
  5.   @UserNickname  varchar(16) OUTPUT,
  6.   @UserErrCount smallint  OUTPUT,
  7.   @UserLastname varchar(32) OUTPUT,
  8.   @Expired int OUTPUT
  9. AS
  10. BEGIN
  11. SET NOCOUNT ON;
  12.  
  13. DECLARE @ExpireDate smalldatetime,@PWChanged smalldatetime
  14.  
  15.  
  16. SELECT distinct @UserNickname = PAEm_Nickname, @UserLastname = PAEm_Lastname, @UserPassword = PAEm_Password, @UserID = PAEm_ID, @UserErrCount = PAEm_ErrCount,@PWChanged = PAEm_PWLastChanged
  17. FROM ADM_PA_Employee, ADM_PA_CntrGlobal
  18. WHERE PAEm_Username = @Username and PACG_FK_PAEm_ID = PAEm_ID and (PACg_Enddate > dateadd(day,-1,getdate()) or PACg_Enddate is null)
  19.  
  20. --Kijken en instellen of het wachtwoord niet is verlopen
  21. SET @ExpireDate = DATEADD(mm,CONVERT(int,(SELECT CMPa_Value FROM ADM_CM_PARAMETERS WHERE CMPa_Code = 'PWExpire')),@PWChanged)
  22. IF @ExpireDate < getdate() SET @Expired = 1
  23. ELSE SET @Expired = 0
  24.  
  25. IF @UserPassword != '' 
  26. begin 
  27. if isnull(@UserNickname,'') = '' 
  28.   SELECT @UserNickname = PAEm_Firstname
  29.   FROM ADM_PA_Employee
  30.   WHERE PAEm_Username = @Username
  31. end
  32.  
  33.  
  34. IF @UserID > 0
  35.   SELECT distinct sysobjects.name
  36.   FROM sysobjects, sysprotects, sysusers, ADM_LS_Groups, ADM_LS_EmployeeGroups, ADM_PA_Employee
  37.   WHERE xtype = 'P' 
  38.     and sysobjects.id = sysprotects.id 
  39.     and sysprotects.uid = sysusers.uid
  40.     and (sysprotects.protecttype = 204 or sysprotects.protecttype = 205)
  41.     and LSGr_Login = sysusers.name
  42.     and LSGr_ID = LSEG_FK_LSGr_ID
  43.     and LSEG_FK_PAEm_ID = PAEm_ID
  44.     and PAEm_ID = @UserID
  45.   ORDER BY sysobjects.nameELSE
  46.  SELECT * FROM ADM_PA_Employee WHERE PAEm_ID = 1 and PAEm_ID = 2
  47. END
  48.  
Expand|Select|Wrap|Line Numbers
  1. dbCom.CommandText = "ADM_LS_SelectUserPassword"
  2. dbCom.CommandType = adCmdStoredProc
  3. dbCom.Parameters.Refresh
  4.  
  5. dbCom(1).Value = strUserName
  6.  
  7. dbRst.Open dbCom
  8.  
  9.  
  10. If dbRst.EOF = True Or dbRst.BOF = True Then
  11.   dbRst.Close
  12.   If Not IsNull(dbCom(2).Value) Then
  13.     Err.Raise 1004, , "User has no permissions: " & strUserName
  14.   Else
  15.     Err.Raise 1000, , "Unknown user: " & strUserName
  16.   End If
  17. Else
  18.   ReDim strGroup(0)
  19.   Do While Not dbRst.EOF
  20.     ReDim Preserve strGroup(UBound(strGroup) + 1)
  21.     strGroup(UBound(strGroup) - 1) = dbRst.Fields(0)
  22.     dbRst.MoveNext
  23.   Loop
  24.   dbRst.Close
  25. End If
  26.  
Sep 11 '06 #1
1 16672
rover
2
A little update.

So it seems that the issue is not related to the return values and recordset.

I have created a small test application which returns a recordset just fine.

Could it be possible that SQL 2005 prevents information from sysobject to be exported (using SQL)?

I have this in a stored procedure where I fetch a list of stored procedures where a user has rights:

Expand|Select|Wrap|Line Numbers
  1. SELECT distinct sysobjects.name
  2.   FROM sysobjects, sysprotects, sysusers, ADM_LS_Groups, ADM_LS_EmployeeGroups, ADM_PA_Employee
  3.   WHERE xtype = 'P' 
  4.     and sysobjects.id = sysprotects.id 
  5.     and sysprotects.uid = sysusers.uid
  6.     and (sysprotects.protecttype = 204 or sysprotects.protecttype = 205)
  7.     and LSGr_Login = sysusers.name
  8.     and LSGr_ID = LSEG_FK_LSGr_ID
  9.     and LSEG_FK_PAEm_ID = PAEm_ID
  10.     and PAEm_ID = @UserID
  11.   ORDER BY sysobjects.name
  12.  
Sep 12 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Vipul Pathak | last post by:
Hello Friends ! I have the Following Code, that Executes a Stored Procedure and Attempt to read a Returned Integer Value from the StoredProc. But It gives Error ... ADODB.Command (0x800A0BB9)...
7
by: JT | last post by:
how can i see a stored procedures return value in ASP??
3
by: sumGirl | last post by:
Hi all. I have a stored procedure on my sql server that returns a simple informtation about that tim a database was backed up. I owuld like to create an HTA that operator types can look at to make...
2
by: Daniel | last post by:
hi ng, i am newbie to sqlserver and my problem seems simple, but i didn't find information about it: How can i display the RETURN @x value of a stored procedure in the sql analyzer of the...
1
by: stjulian | last post by:
I have a stored procedure which returns 2 tables and 1 output value. I want the first table to be assigned to rs1 and the second to rs2. However when I run this, I get the following error as I...
8
by: colmkav | last post by:
Can someone tell me how I can access the return value of a function called from Oracle as opposed to a store proc from oracle? my oracle function is get_num_dates_varposfile. I am only used to...
12
by: Dooza | last post by:
I have a stored procedure that takes a number of inputs, does a bulk insert, and then outputs a recordset. When I run the stored procedure in Server Management Studio I also get a return value from...
6
by: SethM | last post by:
I have a stored procedure that returns a record set. I want to functionalize this so I can have multiple presentations of the same record set. However, I can not get rs_event.open StoreProc to pass...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.