?
Solved

Pass-Through queries with OUTPUT parameters

Posted on 2013-12-18
4
Medium Priority
?
1,108 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
  • 2
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
hnasr earned 1500 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 31

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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

862 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