473,473 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Return Value in a Stored Procedure

Hello Newsgroup !

My Tools are:
Windows 2000, VBA(Access 2000) and MS SQL Server 7.0

I wrote in an *.adp project (Access 2000) a Stored Procedure "xyz"
with parameters a,b

In my VBA Code i wrote:

Dim par As New ADODB.Parameter

Cmd.CommandType = adCmdStoredProc
Cmd.CommandText = "[prcSucheUNRWIAEStichtag]"

Set par = Cmd.CreateParameter("@a", adInteger)
Cmd.Parameters.Append par

Set par = Cmd.CreateParameter("@b", adVarChar, adParamInput, 5)
Cmd.Parameters.Append par

........
Cmd.Parameters(0) = a
Cmd.Parameters(1) = b

Set rsTemp = Cmd.Execute

Now my Problem is the following:

there is an error in the stored procedure and i want to use something like
this:

if @idontknow = '000000000'

Begin
return(1) -- Something <>0
end

How can i use this return value in my VBA code ? Maybe i should ask this
question in an other Newsgroup. Please
let me know in which one

Greetings
Frank
Jul 20 '05 #1
2 17201
>
How can i use this return value in my VBA code ? Maybe i should ask this
question in an other Newsgroup. Please
let me know in which one

you have two main choices, declare an ado paramater specifically as a
return parameter and it will receive the value returned by the sproc,
eg

Set par = Cmd.CreateParameter("ret", adInteger, adParamReturnValue)
Cmd.Parameters.Append par

On completion of your sproc you can access this parameter via
cmd.parameters(0) or cmd.parameters("ret"). NOTE for return parameters
it must be the FIRST declared and appended parameter.
The second choice is to declare a variable('s) in your sproc as output
and then have an ado parameter which is also declared as ouptut to
receive this value. eg
Set par = .CreateParameter("intOutput", adVarChar, adParamOutput, 30).
The second method has the obvious advantage of returning data other
than an integer, eg above it is expecting the return of a variable
declared in the sproc as varchar(30) output.

Dave
Jul 20 '05 #2
On Tue, 30 Sep 2003 15:49:50 +0200, "frank niedermeyer"
<fn**********@aareon.com> wrote:
Hello Newsgroup !

My Tools are:
Windows 2000, VBA(Access 2000) and MS SQL Server 7.0

I wrote in an *.adp project (Access 2000) a Stored Procedure "xyz"
with parameters a,b

In my VBA Code i wrote:

Dim par As New ADODB.Parameter

Cmd.CommandType = adCmdStoredProc
Cmd.CommandText = "[prcSucheUNRWIAEStichtag]"

Set par = Cmd.CreateParameter("@a", adInteger)
Cmd.Parameters.Append par

Set par = Cmd.CreateParameter("@b", adVarChar, adParamInput, 5)
Cmd.Parameters.Append par

.......
Cmd.Parameters(0) = a
Cmd.Parameters(1) = b

Set rsTemp = Cmd.Execute

Now my Problem is the following:

there is an error in the stored procedure and i want to use something like
this:

if @idontknow = '000000000'

Begin
return(1) -- Something <>0
end

How can i use this return value in my VBA code ? Maybe i should ask this
question in an other Newsgroup. Please
let me know in which one

Greetings
Frank

I don't know about access but is SQL Server you could do 2 things;

1) Create an output parameter and assign your value to that.
2) Raise an exception which should be visible in your code, that you
put in a try..catch block.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff Mason | last post by:
Consider the following (questionable, to be sure, but syntactally legal) stored procedure (using the Northwind database): Create Procedure Test As Return (Select Count(*) From Orders) Select *...
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...
2
by: Scott Natwick | last post by:
Hi, Is there a way to obtain the return code from a stored procedure? Here is what I have so far. The procedure executes, but I'm not able to find the return code from the procedure. ...
8
by: Peter | last post by:
Hi, there I have created an stored procedure using the DDL below for my MS Access Database and no error occurs. Also it can create an stored procedure if I changed the parameter from "" to...
5
by: Sandy | last post by:
Hello - I need a good example of how to take a return value from a stored procedure and use it in vb code. I have an app that searches a database by city and state. If a user makes a typo, the...
2
by: philip | last post by:
hello, i am new to asp.net and sql server, and i have 3 questions for asking: 1. i am writing a store procedure of login validation for my asp.net application and wondering what the different...
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...
1
by: psycho | last post by:
How do we return a single value from a stored procedure. Suppose I have a stored procedure like this: create proc dbo.spInsertGroup @ID uniqueidentifier @GroupName varchar(100), @IsActive...
4
by: jleeie | last post by:
Can someone help me, I'm going round in circles with this and my head is cabbaged ! I am using visual studio 2005 & VB & MS SQL 2005 I am trying to execute a stored procedure from within a...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.