473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 1239
Stupid computer!!!

'sp to insert
cmdInsertContractor = New SqlCommand("ins_cntr_mgt_contractor", Conn)
cmdInsertContractor.CommandType = CommandType.StoredProcedure
cmdInsertContractor.Parameters.Add(New SqlParameter("@mid",
Trim(Session("MID"))))
cmdInsertContractor.Parameters.Add(New SqlParameter("@company",
Trim(txtCompany.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@first_name",
Trim(txtFirstName.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@last_name",
Trim(txtLastName.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@email",
Trim(txtEmail.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@mobile",
Trim(txtMobile.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@phone",
Trim(txtPhone.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@position",
Trim(txtPositionHeld.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@ctype",
Trim(rbtnContractorType.SelectedValue)))

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.Direction = ParameterDirection.ReturnValue
cmdInsertContractor.Parameters.Add(returnValue)
' Execute sp here
' After execution, you can read the returncode from returnValue
Console.WriteLine(string.Format("ReturnValue: {0}", returnValue.Value))

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
cmdInsertContractor = New SqlCommand("ins_cntr_mgt_contractor", Conn)
cmdInsertContractor.CommandType = CommandType.StoredProcedure
cmdInsertContractor.Parameters.Add(New SqlParameter("@mid",
Trim(Session("MID"))))
cmdInsertContractor.Parameters.Add(New SqlParameter("@company",
Trim(txtCompany.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@first_name",
Trim(txtFirstName.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@last_name",
Trim(txtLastName.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@email",
Trim(txtEmail.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@mobile",
Trim(txtMobile.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@phone",
Trim(txtPhone.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@position",
Trim(txtPositionHeld.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@ctype",
Trim(rbtnContractorType.SelectedValue)))

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*****@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Adam,

try adding the following code:

Dim returnValue as SqlParameter = New SqlParameter()
returnValue.Direction = ParameterDirection.ReturnValue
cmdInsertContractor.Parameters.Add(returnValue)
' Execute sp here
' After execution, you can read the returncode from returnValue
Console.WriteLine(string.Format("ReturnValue: {0}", returnValue.Value))

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

"Adam Knight" wrote:
Stupid computer!!!

'sp to insert
cmdInsertContractor = New SqlCommand("ins_cntr_mgt_contractor", Conn)
cmdInsertContractor.CommandType = CommandType.StoredProcedure
cmdInsertContractor.Parameters.Add(New SqlParameter("@mid",
Trim(Session("MID"))))
cmdInsertContractor.Parameters.Add(New SqlParameter("@company",
Trim(txtCompany.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@first_name",
Trim(txtFirstName.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@last_name",
Trim(txtLastName.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@email",
Trim(txtEmail.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@mobile",
Trim(txtMobile.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@phone",
Trim(txtPhone.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@position",
Trim(txtPositionHeld.Text)))
cmdInsertContractor.Parameters.Add(New SqlParameter("@ctype",
Trim(rbtnContractorType.SelectedValue)))

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
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...
0
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...
2
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...
4
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...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
4
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...
1
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...
10
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...
4
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...
9
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...
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...
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,...

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.