Suppose there is a procedure
PROCEDURE PRC_VALIDATEUSER(usrName in VARCHAR,usrPwd in VARCHAR,
,usrValid out NUMBER) AS
BEGIN
/*…………*/
END;
Now in C# we write code the following way
Public Boolean validateUser(string pusrname,string pusrpass)
{
Try
{
OracleConnection con = new OracleConnection(appParams.connString);
//instead of appParams.connString use connection string for your database
con.Open();
sql = " begin validateuser(:uName,:uPasswd,:uValid); end;";
OracleParameter p1 = new OracleParameter();
p1.OracleType = OracleType.VarChar;
OracleParameter p2 = new OracleParameter();
p2.OracleType = OracleType.VarChar;
OracleParameter p3 = new OracleParameter();//dept
p3.OracleType = OracleType.Number;
p1.ParameterName = "uName";
p2.ParameterName = "uPasswd";
p3.ParameterName = "uValid";
p1.Value=pusrname;
p2.Value=pusrpass;
OracleCommand cmd = new OracleCommand(sql, con);
cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3);
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
if(p3.value==1)
return true;
else
return false;
}
Catch(System.exception ex)
{
return false;
}
}
No comments:
Post a Comment