Solved

Pass-Through queries with OUTPUT parameters

Posted on 2013-12-18
4
987 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 30

Accepted Solution

by:
hnasr earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now