Hi,
In Asp.Net, i create a stored procedure for login form, if user name and password exists in databases it returns one otherwise zero.
I write the below stored procedure, get an error of Parameter value not supplied
CREATE Procedure comparelogin
(
@name varchar(50),
@password varchar(50),
@RowCount int output
)
As
select count(username) from users where username=@name and user_password=@ password; select @RowCount=@@Row Count
GO
C#
SqlConnection myConn = new SqlConnection(C onfigurationSet tings.AppSettin gs["MyConn"]);
SqlCommand myCmd = new SqlCommand("com parelogin", myConn);
myCmd.CommandTy pe = CommandType.Sto redProcedure;
SqlParameter objParam1;
SqlParameter objParam2;
SqlParameter returnParam;
objParam1 = myCmd.Parameter s.Add("@name", SqlDbType.VarCh ar);
objParam2 = myCmd.Parameter s.Add("@passwor d", SqlDbType.VarCh ar);
returnParam = myCmd.Parameter s.Add("@RowCoun t", SqlDbType.Int);
objParam1.Direc tion = ParameterDirect ion.Input;
objParam2.Direc tion = ParameterDirect ion.Input;
returnParam.Dir ection = ParameterDirect ion.ReturnValue ;
objParam1.Value = txtUser;
objParam2.Value = txtPass;
try
{
/*if (myConn.State.E quals(Connectio nState.Closed))
{
myConn.Open();
myCmd.ExecuteNo nQuery();
}*/
myConn.Open();
myCmd.ExecuteNo nQuery();
if ((int)returnPar am.Value < 1)
{
Label3.Text="In valid Login!";
return false;
}
else
{
myConn.Close();
return true;
}
}
catch (Exception ex)
{
Label3.Text = ex + "Error Connecting to the database";
return false;
}
In Asp.Net, i create a stored procedure for login form, if user name and password exists in databases it returns one otherwise zero.
I write the below stored procedure, get an error of Parameter value not supplied
CREATE Procedure comparelogin
(
@name varchar(50),
@password varchar(50),
@RowCount int output
)
As
select count(username) from users where username=@name and user_password=@ password; select @RowCount=@@Row Count
GO
C#
SqlConnection myConn = new SqlConnection(C onfigurationSet tings.AppSettin gs["MyConn"]);
SqlCommand myCmd = new SqlCommand("com parelogin", myConn);
myCmd.CommandTy pe = CommandType.Sto redProcedure;
SqlParameter objParam1;
SqlParameter objParam2;
SqlParameter returnParam;
objParam1 = myCmd.Parameter s.Add("@name", SqlDbType.VarCh ar);
objParam2 = myCmd.Parameter s.Add("@passwor d", SqlDbType.VarCh ar);
returnParam = myCmd.Parameter s.Add("@RowCoun t", SqlDbType.Int);
objParam1.Direc tion = ParameterDirect ion.Input;
objParam2.Direc tion = ParameterDirect ion.Input;
returnParam.Dir ection = ParameterDirect ion.ReturnValue ;
objParam1.Value = txtUser;
objParam2.Value = txtPass;
try
{
/*if (myConn.State.E quals(Connectio nState.Closed))
{
myConn.Open();
myCmd.ExecuteNo nQuery();
}*/
myConn.Open();
myCmd.ExecuteNo nQuery();
if ((int)returnPar am.Value < 1)
{
Label3.Text="In valid Login!";
return false;
}
else
{
myConn.Close();
return true;
}
}
catch (Exception ex)
{
Label3.Text = ex + "Error Connecting to the database";
return false;
}