string strSQL = "select myuser from tbluser where myuser = :user and mypass = :pass ";
OracleParameter[] parameters = new OracleParameter[] {
new OracleParameter("user","root"),
new OracleParameter("pass","root")
};
string result = dal.executeScalar(strSQL,parameters);
//method Code (C#)
public string executeScalar(string spName, OracleParameter[] parameters)
{
try
{
using (OracleConnection conn = new OracleConnection(strconn))
{
conn.Open();
using (OracleCommand cmd = new OracleCommand(spName, conn))
{
cmd.CommandType = CommandType.Text;
if (parameters != null && parameters.Length > 0)
{
// cmd.Parameters.AddRange(parameters);
foreach (OracleParameter item in parameters)
{
cmd.Parameters.Add(item);
}
}
string result = Convert.ToString(cmd.ExecuteScalar());
conn.Close();
return result;
}
}
}
catch (OracleException ex)
{
throw new Exception("Error SQL " + ex);
}
}