Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Stored Procedure Return Values

Reply
Thread Tools

Stored Procedure Return Values

 
 
Adam Knight
Guest
Posts: n/a
 
      12-14-2005
Hi all,

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

Code: Below:


 
Reply With Quote
 
 
 
 
Adam Knight
Guest
Posts: n/a
 
      12-14-2005
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFpbGV5cw==?=
Guest
Posts: n/a
 
      12-14-2005
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
>
>
>

 
Reply With Quote
 
Patrick.O.Ige
Guest
Posts: n/a
 
      12-14-2005
Adam there are more samples here at:-
http://www.developerfusion.co.uk/show/4278/3/
Patrick

"Baileys" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
Redirect based on stored procedure return values =?Utf-8?B?bmVpbF9wYXQ=?= ASP .Net 3 03-09-2005 12:02 AM
Obtaining the return code from a stored procedure Scott Natwick ASP .Net 2 10-03-2004 12:47 AM
Return a value from stored procedure to calling application Paul ASP .Net 1 01-19-2004 05:06 PM
Stored Procedure has both return value and data set (SqlDataReader) Neo Chou ASP .Net 1 08-03-2003 06:23 AM



Advertisments