Solved

Pass-Through queries with OUTPUT parameters

Posted on 2013-12-18
4
1,060 Views
Last Modified: 2014-01-27
Hi,
I would like to read an output parameter from a SQL stored procedure that I am calling from an MS Access Linked Front End via a pass-through query.

I am opening up an ado recordset using the pass-through which returns the records if criteria is met, however when criteria is not met, I am setting a 'Return_Cde' and 'Return_Msg' output params to messages used by the FE. I am not able to figure out how to reference the output parameter defined in the sp.

Pass-Through Returns Records property set to true.

Thanks.
0
Comment
Question by:Howiee22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 39728189
Here is an example: See if you can adopt in your scenario.
scalar function, checks a parameter value and returns a value.
if object_id(N'ufn_Scalar',N'FN') is not null
	drop function ufn_Scalar;
go
create function dbo.ufn_Scalar (@parameter_name AS nvarchar(25))
RETURNS nvarchar(25)
with execute as caller
AS
BEGIN
	declare @parameter_out nvarchar(25)
	if @parameter_name='1' 
		set @parameter_out='The value is 1'
	else
		set @parameter_out='The value is not 1'
	RETURN (@parameter_out)
END;

Open in new window


Here is a pass-through query in Access front end: When you run it, asks you for the DSN
SELECT dbo.ufn_Scalar('2');
'Result
'The value is not 1

Open in new window

0
 

Author Comment

by:Howiee22
ID: 39729105
Thanks. I will give this a try. One thing I was able to determine, is if I open an ADO recordset  to the results of the sp, then I am not able to read the output parameter. If I close the recordset, then I can access the value of the parameter as set in the sp. Is there another way to approach this as to being able to read output AND continue using the recordset?
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39730159
If you can help in creating the issue, I might be able to answer.
Try to send the sql to create a table in MSSQL, and a simple Access FE.
0
 

Author Comment

by:Howiee22
ID: 39814023
Hi, sorry for not getting back to this... From what I was able to determine, once you close the recordset object, I am able to access the output/return variables.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question