Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2006, 05:02 PM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get value from stored proc

I am calling a strored procedure from my asp .net application. How do I get the value of the result into the application back ? What are the classes to use for this..can any body show me the code examples pls
:)

 
Old April 1st, 2006, 12:47 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You need to specify an output paramter in the sp.. EX:
create mysp
@id int,
@myreturn varchar(10) OUTPUT
as

set @myreturn = 'A Test'


Then in your .NET code:

create a command or adapter object
dim mycommand as new sqlcommand

..set properties.. params..etc
dim myreturn as string
mycommand.executenonquery
myreturn = mycommand.parameters("@myreturn").value

Jim


 
Old April 1st, 2006, 04:45 PM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx Jim.
But I am getting an error like this.
Procedure 'mysp' expects parameter '@myreturn', which was not supplied

 
Old April 1st, 2006, 05:24 PM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I required to do is, I want to pass a parameter to the procedure which is an Itemcode. And from 5 related tables I want to fetch 8 information and display them on a form in 7 textBox controls and in 1 image control. So basically I need 8 output parameters. I cannot use the datareader because I will not be able to bind them to this control. How can I write code to get all these info from the tables and present it on the form.

 
Old April 2nd, 2006, 01:06 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

In that case you do not use return parameters. Simply create a sql select statment. I would use a sqldataadapter and fill a dataset. The textboxes and image controls can then be bound to columns in the dataset table.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Proc that returns a value elygp SQL Server 2000 4 May 9th, 2007 01:05 AM
Calling an insert stored proc from a select stored dzitam SQL Language 10 April 2nd, 2007 12:39 PM
optional where in stored proc david_ste SQL Server ASP 2 October 27th, 2005 07:16 AM
How i can OUTPUT in Stored Proc yoord SQL Server 2000 2 July 19th, 2004 03:11 PM
Simplify the stored proc stephanel SQL Server 2000 3 August 5th, 2003 08:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.