Converting varchar2 datatype to a C# Byte Array
445592Jul 19 2005 — edited Jul 26 2005I am having trouble converting varchar2 datatype to Byte array. Basically I am trying to retrieve password which is stored as RAW datatype in the table.
In my C# code, I need the to return it as Byte array.
Any help would be appreciated.
UserRoleManager manager = new UserRoleManager();
byte[] hashedPassword = manager.GetPassword(userName);
public class UserRoleManager
{
public byte[] GetPassword(string userName)
{
OracleConnection Conn = new OracleConnection();
Conn.ConnectionString = "Data Source=testing;User ID=security;Password=security";
Conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = Conn;
cmd.CommandText = "GetPassword";
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter password = new OracleParameter();
password.Direction = ParameterDirection.Output;
password.Size = 300;
cmd.Parameters.Add(password);
cmd.Parameters.Add("Name",OracleDbType.Varchar2,ParameterDirection.Input).
Value = userName;
cmd.ExecuteNonQuery();
byte[] _password = (byte[])password.Value;
return _password;
}
}
CREATE OR REPLACE PROCEDURE getpassword
(
name IN VARCHAR2 DEFAULT NULL,
password IN OUT VARCHAR2
)
AS
BEGIN
SELECT password INTO getpassword.password
FROM Users
WHERE UserName = name;
RETURN;
END;
/