473,779 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Output value stored procedure dotnet

Hi Guys,

Im attempting to get an output value from my stored procedure. Im
pulling my hair out at this one. any help appreciated.
my code is as follows:

Dim cnstring As String
Dim iConn As New SqlClient.SqlCo nnection(strReg istry)
Dim iDataAdapter As New SqlClient.SqlDa taAdapter
Dim iDataSet As New DataSet
Dim err As String
Dim cmd As New SqlCommand

Try

iConn.Open()
cmd.Connection = iConn
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = SQLStr

Dim myParam1 As SqlParameter =
cmd.Parameters. Add("@Threshhol d", SqlDbType.VarCh ar, 50)
myParam1.Direct ion = ParameterDirect ion.Input
myParam1.Value = String.Empty

Dim myParam2 As SqlParameter =
cmd.Parameters. Add("@Return", SqlDbType.VarCh ar, 50)
myParam2.Direct ion = ParameterDirect ion.Output

iDataAdapter = New SqlClient.SqlDa taAdapter
iDataAdapter = New SqlDataAdapter( cmd)
cmd.ExecuteNonQ uery()
iDataAdapter.Fi ll(iDataSet, "tblRoleReturne d")
Dim s As String = cmd.Parameters( "@Return").Valu e
SQLDSReturn = iDataSet

**********STORE D PROCEDURE****** *************** *************** *********

CREATE PROCEDURE OADsp_SelectUna ssignedReferral s

@Return varchar(50) output,
@Threshhold int

as

Set @Threshhold = 60

SELECT * FROM tbl_Referrals
WHERE (AssignedStaffI D IS NULL AND TimeAssigned IS NULL)
OR (ReferralStaffI D IS NULL AND
DateDiff(SECOND ,(TimeAssigned) ,(GETDATE())) @Threshhold)

IF @@ERROR>0
BEGIN
RETURN 99
END
ELSE
BEGIN
RETURN 1
END
GO

Aug 17 '06 #1
1 3255
You're not trying to get the output parameter, prior to running through your
result set generated by the select statement, are you?

"csgraham74 " wrote:
Hi Guys,

Im attempting to get an output value from my stored procedure. Im
pulling my hair out at this one. any help appreciated.
my code is as follows:

Dim cnstring As String
Dim iConn As New SqlClient.SqlCo nnection(strReg istry)
Dim iDataAdapter As New SqlClient.SqlDa taAdapter
Dim iDataSet As New DataSet
Dim err As String
Dim cmd As New SqlCommand

Try

iConn.Open()
cmd.Connection = iConn
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = SQLStr

Dim myParam1 As SqlParameter =
cmd.Parameters. Add("@Threshhol d", SqlDbType.VarCh ar, 50)
myParam1.Direct ion = ParameterDirect ion.Input
myParam1.Value = String.Empty

Dim myParam2 As SqlParameter =
cmd.Parameters. Add("@Return", SqlDbType.VarCh ar, 50)
myParam2.Direct ion = ParameterDirect ion.Output

iDataAdapter = New SqlClient.SqlDa taAdapter
iDataAdapter = New SqlDataAdapter( cmd)
cmd.ExecuteNonQ uery()
iDataAdapter.Fi ll(iDataSet, "tblRoleReturne d")
Dim s As String = cmd.Parameters( "@Return").Valu e
SQLDSReturn = iDataSet

**********STORE D PROCEDURE****** *************** *************** *********

CREATE PROCEDURE OADsp_SelectUna ssignedReferral s

@Return varchar(50) output,
@Threshhold int

as

Set @Threshhold = 60

SELECT * FROM tbl_Referrals
WHERE (AssignedStaffI D IS NULL AND TimeAssigned IS NULL)
OR (ReferralStaffI D IS NULL AND
DateDiff(SECOND ,(TimeAssigned) ,(GETDATE())) @Threshhold)

IF @@ERROR>0
BEGIN
RETURN 99
END
ELSE
BEGIN
RETURN 1
END
GO

Aug 17 '06 #2

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

Similar topics

5
8306
by: Steve Holden | last post by:
Has anyone, with any driver whatsoever, managed to retrieve output parameters from a SQL Server stored procedure? I've just been rather embarrassed to find out it's not as easy as it might seem, and people are saying bad things about Python as a result :-( mx.ODBC, which I regard as a highly-capable module, does not support the callproc() API, and suggests use of the ODBC call format. It has caveats in (some of) the documentation...
2
10392
by: Begoña | last post by:
in my java application I've made a call to this stored procedure CREATE procedure pruebaICM @pANI varchar(20), @pTABLA varchar(20), @pInsert varchar(500), @pUpdate varchar(1000), @pFLAG varchar(1), @pResultado int OUTPUT
4
2190
by: Steven | last post by:
I'm calling a stored procedure which has an output parameter of type int. Once the stored procedure is executed, I want to check the value of the parameter in case it is null. However, when the a null value is returned I don't seem to be able to detect it. Any help would be greatly appreciated. C# code is as follows: SqlCommand cmd = new SqlCommand("sp_GetApplicationID", conn);
4
45145
by: laurenq uantrell | last post by:
I need to get the value of an output parameter back into my VBA function calling a stored procedure. I'm using the following construction to append a new record in a SQL Server table: Function ThisFunctionInsertsANewRecord() On Error GoTo myErr Dim cmd As ADODB.Command
8
14020
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY STORE_NAME OPEN @RETCUR
8
4457
by: Christopher Weaver | last post by:
I'm having trouble accessing the value of an output parameter of a stored procedure. The SP looks like this: SET TERM ^ ; CREATE PROCEDURE SP_NEW_TASK RETURNS ( "uidTask" INTEGER) AS begin
5
6521
by: MS | last post by:
Here's my simple stored procedure: ALTER PROCEDURE GetMemberIDByEmail @Email EmailAddress, @ID int OUTPUT AS SELECT @ID = ID FROM tbl_Member WHERE Email=@Email RETURN
8
2158
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 ""@zSampleName". OleDbcmd.CommandText = _ "CREATE PROCEDURE udpGetSampleIDByName" & vbCrLf & _ "( VarChar(64))" & vbCrLf & _ "AS" & vbCrLf & _
4
1688
by: Tifer | last post by:
Hello, I'm still new to the whole .Net thing and I'm having a problem with something that should be so simple -- executing a query and returning an output parameter. It's a standard "Add" stored procedure, where I add a user to the database. I insert the record, and return the user's ID. I can run it just fine and it does execute the code because the user is being inserted successfully. But I can't receive any output values.
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6724
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.