CREATE TABLE MYUSE100(userid number,username varchar2(45),ppassword varchar2(50));
insert into MYUSE200 values('harry','potter');
here is my stored procedure
create or replace procedure p_myuse200(p_username1 in varchar2,p_password1 in varchar2,v_count out number)
AS
BEGIN
select count(*) INTO v_count from MYUSE200 where username1=p_username1 and password1=p_password1;
IF v_count>0 THEN
v_count:=v_count+0;
ELSE
v_count:=0;
END IF;
END;
/
codebehind
protected void button1_onclick(object sender, EventArgs e)
{
OracleConnection conn = new OracleConnection(strConnString);
OracleCommand cmd = new OracleCommand("p_myuse200",conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
OracleParameter username1 = new OracleParameter("p_username1", OracleDbType.Varchar2, 50);
username1.Value = textbox1.Text;
cmd.Parameters.Add(username1);
OracleParameter password1 = new OracleParameter("p_password1 ", OracleDbType.Varchar2, 45);
password1.Value = textbox2.Text;
cmd.Parameters.Add(password1);
cmd.Parameters.Add("v_count", OracleDbType.Varchar2, 30);
cmd.Parameters["v_count"].Direction = ParameterDirection.Output;
Int32 results = 0;
//results = (Int32)cmd.Parameters["v_count"].Value;
try
{
results = Convert.ToInt32(cmd.Parameters["values"].Value);
cmd.ExecuteScalar();
//cmd.ExecuteNonQuery();
if (results > 0)
{
Response.Redirect("http://www.google.com");
}
else
{
Response.Redirect("http://www.facebook.com");
}
conn.Close();
conn.Dispose();
}
catch (Exception ex)
{
Response.Redirect("http://www.gmail.com");
}
}
}
I'm unable to login any suggestions, both in case of stored procedure and codebehind.
results>0 is not getting the current value count=1 and results should be 1 but it is always zero and else block is executing,,,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…