Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 June 26th, 2004, 03:52 AM
Friend of Wrox
Join Date: May 2004
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default how i use the Stored Procedure return value and ho

how i use the Stored Procedure return value and how i can use it in ADO.NET using C# Code

Any One Tell me how i can use N'Switch in SQL Server Stored Procedure .
When I use Such a this syntax i am encountered and stoped with a error.
the is below(Stoerd Prdocedure Code)
CREATE proc sp_check_userpass(@username nvarchar(50),@password nvarchar(50),@first nvarchar(50),@last nvarchar(50),@email nvarchar(50),@stage int )as
declare @cnt int
select @cnt=count(*) from member_info where (@username=username and @password=password)
insert into atable(first,last,username,password,stage) values(@first,@last,@username,@password,@stage)
return @cnt
Other thing is that when exec this store proc it must be return a value return back to the @cnt but it is return only This( The command(s) Completed succefully).
Any One guide me how i can must be do .
i must clear it that i am using this query in ASP.NET SqlClient Object To Execute Query.
i am using this code in my asp.net page
SqlCommand objCommand=new SqlCommand("sp_check_user_pass",objConnection);
objCommand.CommandType=CommandType.StoredProcedu re;
objCommand.Parameters.Add(new SqlParameter("@username",SqlDbType.NVarChar,50)).V alue=username.Text;
objCommand.Parameters.Add(new SqlParameter("@password",SqlDbType.NVarChar,50)).V alue=password.Text;
objCommand.Parameters.Add(new SqlParameter("@first",SqlDbType.NVarChar,50));//.Value=username.Text;
objCommand.Parameters.Add(new SqlParameter("@last",SqlDbType.NVarChar,50));
objCommand.Parameters.Add(new SqlParameter("@username",SqlDbType.NVarChar,50));
objCommand.Parameters.Add(new SqlParameter("@password",SqlDbType.NVarChar,50));
objCommand.Parameters.Add(new SqlParameter("@email",SqlDbType.NVarChar,50));
SqlParameter SqlParam=objCommand.Parameters.Add(new SqlParameter("@cnt" ,SqlDbType.Int));
             SqlParam.Direction=ParameterDirection.ReturnVa lue;
     Response.Write("user exists"); }
Response.Write("user not exist");
it is run without any error but dont insert any value into table

Thanx In Advance. YoOrD.
       YoOrD .
Beauty is not on the face
Beauty is on the heart
~~<<Ghibran Khalil>>~~
Old June 26th, 2004, 04:36 AM
Friend of Wrox
Join Date: Jun 2004
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi

I think you are doing wrong in your sql queery which is

select @cnt=count(*) from member_info where (@username=username and @password=password)

I think it should be
@cnt = select count(*) from member_info where (username = @username and password =@password )

Love 4 all
Old June 26th, 2004, 04:10 PM
Friend of Wrox
Join Date: May 2004
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post

quote:Originally posted by qazi_nomi
 I think you are doing wrong in your sql queery which is

select @cnt=count(*) from member_info where (@username=username and @password=password)

I think it should be
@cnt = select count(*) from member_info where (username = @username and password =@password )

Love 4 all
thank to u but it isnt work and stoped with many error any other solution if think i must use.
thanks in advance YoOrD.
Old June 27th, 2004, 02:04 AM
Friend of Wrox
Join Date: May 2004
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post

my problem yet not solved.
if any one to guide me what i must do.
regards YoOrD.

Old June 27th, 2004, 05:26 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Well, if it doesn't work, it's usually a very good idea to tell people what doesn't work. Just saying "and stoped with many error" is not really a very good description of the problem.

Also, realize it's weekend and many people are in an other hemisphere than you are. This means that other people are asleep while you're waiting for an answer. This means you not always get it as quick as you'd want.


Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Me and my monkey by Robbie Williams (Track 10 from the album: Escapology) What's This?
Old June 28th, 2004, 08:39 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts

Didn't we do this before?

Here: http://p2p.wrox.com/topic.asp?TOPIC_ID=14681
And here: http://p2p.wrox.com/topic.asp?TOPIC_ID=14646
And here: http://p2p.wrox.com/topic.asp?TOPIC_ID=14084 (in the bottom of the thread)
And Here: http://p2p.wrox.com/topic.asp?TOPIC_ID=15031

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee

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
[Resolved] Get return value from stored procedure snufse ASP.NET 2.0 Basics 1 August 8th, 2008 11:05 AM
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 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.