Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 26th, 2004, 03:52 AM
Friend of Wrox
 
Join Date: May 2004
Location: Ardabil, Ardabil, Iran.
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
begin
select @cnt=count(*) from member_info where (@username=username and @password=password)
if(@cnt=0)
begin
insert into atable(first,last,username,password,stage) values(@first,@last,@username,@password,@stage)
end
else
return @cnt
end
GO
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
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["@first"].Value=first.Text;
objCommand.Parameters.Add(new SqlParameter("@last",SqlDbType.NVarChar,50));
objCommand.Parameters["@last"].Value=last.Text;
objCommand.Parameters.Add(new SqlParameter("@username",SqlDbType.NVarChar,50));
objCommand.Parameters["@username"].Value=username.Text;
objCommand.Parameters.Add(new SqlParameter("@password",SqlDbType.NVarChar,50));
objCommand.Parameters["@password"].Value=password.Text;
objCommand.Parameters.Add(new SqlParameter("@email",SqlDbType.NVarChar,50));
             objCommand.Parameters["@email"].Value=email.Text;
SqlParameter SqlParam=objCommand.Parameters.Add(new SqlParameter("@cnt" ,SqlDbType.Int));
             SqlParam.Direction=ParameterDirection.ReturnVa lue;
             objConnection.Open();
        try
    {
     objCommand.ExecuteNonQuery();
     rowcount=(int)objCommand.Parameters["@cnt"].Value;
    if(rowcount>0)
     {
     Response.Write("user exists"); }
    else
    {
Response.Write("user not exist");
Response.Write("cnt"+rowcount);//
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
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>>~~
Reply With Quote
  #2 (permalink)  
Old June 26th, 2004, 04:36 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

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
Reply With Quote
  #3 (permalink)  
Old June 26th, 2004, 04:10 PM
Friend of Wrox
 
Join Date: May 2004
Location: Ardabil, Ardabil, Iran.
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
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.
Reply With Quote
  #4 (permalink)  
Old June 27th, 2004, 02:04 AM
Friend of Wrox
 
Join Date: May 2004
Location: Ardabil, Ardabil, Iran.
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

Reply With Quote
  #5 (permalink)  
Old June 27th, 2004, 05:26 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.

Cheers,

Imar
---------------------------------------
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?
Reply With Quote
  #6 (permalink)  
Old June 28th, 2004, 08:39 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.