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>>~~
|