473,406 Members | 2,705 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,406 software developers and data experts.

asp.net stored procedure return value question

Hi guys,

I can't figure out why this is not working? I need to display all the
rows for a given query for a given page index (ex. row 10..20) and the
total number of rows. I got the first part to work. However, when I
added the return parameter value, the first part is empty but I do get
total number of rows.

da.SelectCommand.CommandText = "CommentsByPaging";
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("PageInde x", PageIndex);
da.SelectCommand.Parameters.AddWithValue("PageSize ", PageSize);

da.SelectCommand.Parameters.Add("@CommentCount", SqlDbType.Int);
da.SelectCommand.Parameters["@CommentCount"].Direction =
ParameterDirection.Output;

It's suppose to get comments for a given page index and the total
number of comments available. I got the comments for a given page
index to work, however now that I've added 'CommentCount', this total
number of comments works but my dataset.tables.count is empty? Any
idea what I'm doing wrong.

Stored procedure..
ALTER PROCEDURE [dbo].[CommentsByPaging]
@PageIndex INT,
@PageSize INT,
@CommentCount INT OUTPUT

I have select for return rows x..n rows
and another select that
SELECT @CommentCount = (SELECT COUNT(CommentId) FROM Comments) that
returns the total rows

Thank you
Maz.

Nov 2 '07 #1
1 4016
mazdotnet wrote:
Hi guys,

I can't figure out why this is not working? I need to display all the
rows for a given query for a given page index (ex. row 10..20) and the
total number of rows. I got the first part to work. However, when I
added the return parameter value, the first part is empty but I do get
total number of rows.

da.SelectCommand.CommandText = "CommentsByPaging";
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("PageInde x", PageIndex);
da.SelectCommand.Parameters.AddWithValue("PageSize ", PageSize);

da.SelectCommand.Parameters.Add("@CommentCount", SqlDbType.Int);
da.SelectCommand.Parameters["@CommentCount"].Direction =
ParameterDirection.Output;

It's suppose to get comments for a given page index and the total
number of comments available. I got the comments for a given page
index to work, however now that I've added 'CommentCount', this total
number of comments works but my dataset.tables.count is empty? Any
idea what I'm doing wrong.

Stored procedure..
ALTER PROCEDURE [dbo].[CommentsByPaging]
@PageIndex INT,
@PageSize INT,
@CommentCount INT OUTPUT

I have select for return rows x..n rows
and another select that
SELECT @CommentCount = (SELECT COUNT(CommentId) FROM Comments) that
returns the total rows

Thank you
Maz.
You have to read all the rows from the data reader before you can read
the value of the output parameter.

--
Göran Andersson
_____
http://www.guffa.com
Nov 2 '07 #2

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

Similar topics

8
by: C Kirby | last post by:
In SQL Server 2000, I've got a rather lengthy stored procedure, which creates a lot of temporary tables as it processes down through a few sets of data. When testing it through Query Analyzer, it...
15
by: Jarrod Morrison | last post by:
Hi All Im generally a vb programmer and am used to referencing multiple records returned from a query performed on an sql database and im trying to move some functions of my software into sql...
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: Daniel | last post by:
hi ng, i am newbie to sqlserver and my problem seems simple, but i didn't find information about it: How can i display the RETURN @x value of a stored procedure in the sql analyzer of the...
4
by: laurenq uantrell | last post by:
I need to get the value of an output parameter back into my VBA function calling a stored procedure. I'm using the following construction to append a new record in a SQL Server table: ...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
by: Sandy | last post by:
Hello - I need a good example of how to take a return value from a stored procedure and use it in vb code. I have an app that searches a database by city and state. If a user makes a typo, the...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
2
by: philip | last post by:
hello, i am new to asp.net and sql server, and i have 3 questions for asking: 1. i am writing a store procedure of login validation for my asp.net application and wondering what the different...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.