Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting varchar2 datatype to a C# Byte Array

445592Jul 19 2005 — edited Jul 26 2005
I 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;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2005
Added on Jul 19 2005
4 comments
1,875 views