473,662 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.SelectComman d.CommandText = "CommentsByPagi ng";
da.SelectComman d.CommandType = CommandType.Sto redProcedure;
da.SelectComman d.Parameters.Ad dWithValue("Pag eIndex", PageIndex);
da.SelectComman d.Parameters.Ad dWithValue("Pag eSize", PageSize);

da.SelectComman d.Parameters.Ad d("@CommentCoun t", SqlDbType.Int);
da.SelectComman d.Parameters["@CommentCo unt"].Direction =
ParameterDirect ion.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].[CommentsByPagin g]
@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 4027
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.SelectComman d.CommandText = "CommentsByPagi ng";
da.SelectComman d.CommandType = CommandType.Sto redProcedure;
da.SelectComman d.Parameters.Ad dWithValue("Pag eIndex", PageIndex);
da.SelectComman d.Parameters.Ad dWithValue("Pag eSize", PageSize);

da.SelectComman d.Parameters.Ad d("@CommentCoun t", SqlDbType.Int);
da.SelectComman d.Parameters["@CommentCo unt"].Direction =
ParameterDirect ion.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].[CommentsByPagin g]
@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
11326
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 runs fine (a bit slow though). But when I try to run it through the ade, it doesn't do anything. It runs through the procedure in milliseconds but doesn't seem to ever actually start it. If I change the calling code in the ade VBA to refer to...
15
6001
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 stored procedures. So far ive been able to move the functions relatively easily but im unsure about how to output multiple values from an sql stored procedure. By this i mean for example one of the stored procedures may take your username and return...
0
6695
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 Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
2
3404
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 sqlserver? thanks a lot, d
4
45102
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: Function ThisFunctionInsertsANewRecord() On Error GoTo myErr Dim cmd As ADODB.Command
2
5450
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
6831
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 info sent to the stored procedure makes the stored procedure fail. I want to be able to display a label indicating they should try again, if this is the case. I can't use row count, because the stored procedure doesn't get that far. What...
7
9703
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 for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for doing it like this is that I also have had a problem in the past where the SP takes longer than the...
2
2671
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 between RETURN and SELECT is. if exists(select * from users where username = @username and password = @password) BEGIN
9
4136
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. When calling the stored procedure from VB.NET, in the CommandText, can I just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with "INSERT_INTO_MYTABLE" then do the following : OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.