473,782 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored Procedure Return Values

Hi all,

I am wanting to get a stored procedure return value via ADO.NET..

Code: Below:
Dec 14 '05 #1
3 1253
Stupid computer!!!

'sp to insert
cmdInsertContra ctor = New SqlCommand("ins _cntr_mgt_contr actor", Conn)
cmdInsertContra ctor.CommandTyp e = CommandType.Sto redProcedure
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ mid",
Trim(Session("M ID"))))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ company",
Trim(txtCompany .Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ first_name",
Trim(txtFirstNa me.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ last_name",
Trim(txtLastNam e.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ email",
Trim(txtEmail.T ext)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ mobile",
Trim(txtMobile. Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ phone",
Trim(txtPhone.T ext)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ position",
Trim(txtPositio nHeld.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ ctype",
Trim(rbtnContra ctorType.Select edValue)))

What do i need to add to create a return value parameter?

Cheers,
Adam
Dec 14 '05 #2
Adam,

try adding the following code:

Dim returnValue as SqlParameter = New SqlParameter()
returnValue.Dir ection = ParameterDirect ion.ReturnValue
cmdInsertContra ctor.Parameters .Add(returnValu e)
' Execute sp here
' After execution, you can read the returncode from returnValue
Console.WriteLi ne(string.Forma t("ReturnValu e: {0}", returnValue.Val ue))

check out
http://msdn.microsoft.com/library/de...turnvalues.asp (watch line-wraps) for more info...

HTH,
Baileys

"Adam Knight" wrote:
Stupid computer!!!

'sp to insert
cmdInsertContra ctor = New SqlCommand("ins _cntr_mgt_contr actor", Conn)
cmdInsertContra ctor.CommandTyp e = CommandType.Sto redProcedure
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ mid",
Trim(Session("M ID"))))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ company",
Trim(txtCompany .Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ first_name",
Trim(txtFirstNa me.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ last_name",
Trim(txtLastNam e.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ email",
Trim(txtEmail.T ext)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ mobile",
Trim(txtMobile. Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ phone",
Trim(txtPhone.T ext)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ position",
Trim(txtPositio nHeld.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ ctype",
Trim(rbtnContra ctorType.Select edValue)))

What do i need to add to create a return value parameter?

Cheers,
Adam

Dec 14 '05 #3
Adam there are more samples here at:-
http://www.developerfusion.co.uk/show/4278/3/
Patrick

"Baileys" <Ba*****@discus sions.microsoft .com> wrote in message
news:E5******** *************** ***********@mic rosoft.com...
Adam,

try adding the following code:

Dim returnValue as SqlParameter = New SqlParameter()
returnValue.Dir ection = ParameterDirect ion.ReturnValue
cmdInsertContra ctor.Parameters .Add(returnValu e)
' Execute sp here
' After execution, you can read the returncode from returnValue
Console.WriteLi ne(string.Forma t("ReturnValu e: {0}", returnValue.Val ue))

check out
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconinputoutpu tparametersretu rnvalues.asp (watch line-wraps) for more
info...
HTH,
Baileys

"Adam Knight" wrote:
Stupid computer!!!

'sp to insert
cmdInsertContra ctor = New SqlCommand("ins _cntr_mgt_contr actor", Conn)
cmdInsertContra ctor.CommandTyp e = CommandType.Sto redProcedure
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ mid",
Trim(Session("M ID"))))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ company",
Trim(txtCompany .Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ first_name",
Trim(txtFirstNa me.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ last_name",
Trim(txtLastNam e.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ email",
Trim(txtEmail.T ext)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ mobile",
Trim(txtMobile. Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ phone",
Trim(txtPhone.T ext)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ position",
Trim(txtPositio nHeld.Text)))
cmdInsertContra ctor.Parameters .Add(New SqlParameter("@ ctype",
Trim(rbtnContra ctorType.Select edValue)))

What do i need to add to create a return value parameter?

Cheers,
Adam

Dec 14 '05 #4

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

Similar topics

7
9012
by: Bill Kellaway | last post by:
Hi there - this should be fairly simple for someone. Basically I can't figure out how to pass the parameters from ASP to a Stored Procedure on SQL. Here's my code: I just need to help in learning how to pass these varibables from ASP to the SP.
0
6704
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
2
5125
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data store. I've done a fair amount of research on concurrency handling in newsgroups and other resources. Below is what I've come up as a standard for handling concurrency thru stored procedures. I am sharing with everyone so I can get some comments...
4
2073
by: Ecohouse | last post by:
I have a quick question for you about SQL stored procedures. If I'm in a stored procedure and want to call another stored procedure and return values from the second stored procedure what is the procedure? I know you do the following to run the second stored procedure and pass in any parameters: EXEC GetAuthorBooks @AuthorID So if I wanted the GetAuthorBooks to return all the books for an author and then populate a temp table in the...
2
5459
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
4
50416
by: Mr Not So Know It All | last post by:
im new to SQL Server and ASP.Net. Here's my problem. I have this SQL Server stored procedure with an input parameter and output parameter CREATE PROCEDURE . @in_rc varchar(8) @out_eList varchar(7) output AS select @out_eList = ecuid from _organization where rccode = @in_rc GO
1
13669
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start procedure============= Create PROCEDURE get_timedout_scripts (
10
2942
by: J. S. EDV | last post by:
Hello, I have got a little problem with stored procedures and C#. I have got a stored procedure which should only insert something in a table. For example: ALTER PROCEDURE DBO.PROC1 AS insert into dbo.Test values ('test')
4
4363
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier Architecture. The Stored Procedures are used through TableAdaptors, which in turn are used by Class Files. I wish to be able to return this new ID value using the Stored
9
4147
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table. When calling the stored procedure from VB.NET, in the CommandText, can I just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with "INSERT_INTO_MYTABLE" then do the following : OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
0
9641
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10146
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
10080
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
9944
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
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

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.