I have Problem in using Stored Procedure in ADO.Net With C# .
i am usin Such a code The send Username And Password to a sql server db and return the nubmer that specifying if a record is found or not found but i dont get proper result in any one to help me.
stored procedure code
CREATE proc sp_check_user_pass(@username nvarchar(50),@password nvarchar(50) )as
begin
select count(*) as num from member_info where (@username=username and @password=password)
return @@rowcount
end
GO
and in the my asp.net page i am using such a below code
Code:
SqlConnection objConnection=new SqlConnection(strConnection);
if(Page.IsPostBack)
{
SqlCommand objCommand=new SqlCommand"sp_check_user_pass",objConnection);
SqlConnection(strConnection);
objCommand.CommandType=CommandType.StoredProcedure;
objCommand.Parameters.Add(new SqlParameter("@username",SqlDbType.NVarChar,50)).Value=username.Text;
objCommand.Parameters.Add(new SqlParameter("@password",SqlDbType.NVarChar,50)).Value=password.Text;
SqlParameter SqlParam=objCommand.Parameters.Add(new SqlParameter("@RowCount" ,SqlDbType.Int));
SqlParam.Direction=ParameterDirection.ReturnValue;
objConnection.Open();
try
{
objCommand.ExecuteNonQuery();
int rowcount=(int); objCommand.Parameters["@RowCount"].Value;
con_open.Text="Number Of Affected Records= "+rowcount;
It must return 1 when no such record is exist in database otherwise return 0 .
but its return 1 for both of them.
Any One Help
And Any One to tell me how I can declare variable in Stored Procedure that i get or return record count(*)
thankx in advance.
YoOrD.