Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 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
  #1 (permalink)  
Old April 10th, 2007, 02:58 AM
Authorized User
 
Join Date: Mar 2007
Location: Beijing, Beijing, China.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to erictamlam Send a message via MSN to erictamlam Send a message via Yahoo to erictamlam
Default Stored Procedure Return Problem in C# Programme

Hey Experts
Is there any way that through stored procedure can it return both enquiry result set and a value.
I created a stored procedure to retrieve product Info with prices between "Min" and "Max",these two parameters are provided by two textBox Control. then I wanna show the enquiry result in a listview and also product quantity in another textBox,How can I make it?

I think the programme only allows me to return either of them because either cmd.ExecuteReader() or cmd.ExecuteScalar() can be run at one time.any way to make it?

thanks for your help!

ERIC
__________________
ERIC
  #2 (permalink)  
Old April 10th, 2007, 07:52 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you call the query using a stored procedure, you could use output parameters. You could also use the default return value parameter ("@Return").

What are you doing with the results of the query? If you are binding the query results to some control, then it's likely that you could use some property of the control to get the number of items bound to it.

-Peter
  #3 (permalink)  
Old April 10th, 2007, 09:37 AM
Authorized User
 
Join Date: Mar 2007
Location: Beijing, Beijing, China.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to erictamlam Send a message via MSN to erictamlam Send a message via Yahoo to erictamlam
Default

Thanks for your help,Peter. I did use output parameter to store number of items.I got it to work this way:
first step: cmd.ExecuteNonQuery() to get the number of items through an output parameter
second step: cmd.ExecuteReader() to return query results and display them in a listview.
I just need to run both of them one after another.LUCKY it worked.
I'm not so familiar with the usage of ListView so I dunno which property I should use to get the number of items.But I guess there must be one.You mind tip me again?
Thanks anyway,great appreciation.

ERIC
  #4 (permalink)  
Old April 10th, 2007, 10:25 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm not sure exactly what it is, but it's likely to be something like ListView.Items.Count.

-Peter
  #5 (permalink)  
Old April 10th, 2007, 09:53 PM
Authorized User
 
Join Date: Mar 2007
Location: Beijing, Beijing, China.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to erictamlam Send a message via MSN to erictamlam Send a message via Yahoo to erictamlam
Default

thanks,I'll check it out!

ERIC


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure return value is NULL kshort ASP.NET 2.0 Basics 16 March 14th, 2017 12:45 PM
Stored Procedure return value dmiles C# 3 December 6th, 2007 05:20 AM
how can i return a recrdset in a stored procedure? arathy ASP.NET 1.0 and 1.1 Basics 0 December 12th, 2006 04:24 AM
Can i return a recordset in a Stored procedure chiefouko VB Databases Basics 6 December 12th, 2006 03:34 AM
Can i return a recordset in a Stored procedure chiefouko SQL Server 2000 1 June 23rd, 2003 06:13 AM





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