Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC\Oracle Question

Status
Not open for further replies.

euntair

Programmer
Sep 13, 2007
53
US
I am using a DSN connection to an Oracle database and am having problems with getting the syntax correct for stored procedures/fucntions. Below is what I have so far:

This function is working
var password varchar2(70);
exec :password := cascade.ae.get_password('srider');
print password;

returns
PASSWORD
--------------------------------------------------------------------------------------------------------------------------------
wRFSg8UAUJ2OHj0ZNoSeOAAw55o=


gave me
public bool validate_account(string account, string password) {

//this._dbc = new OdbcCommand("cascade.ae.get_password");
//this._dbc = new OdbcCommand("ae.get_password");
this._dbc = new OdbcCommand("get_password");

this._dbc.CommandType = CommandType.StoredProcedure;

//this._dbc.Parameters.Add("@v_account", OdbcType.VarChar, 70);
//this._dbc.Parameters["@v_account"].Value = account;
//this._dbc.Parameters["@v_account"].Direction = ParameterDirection.Input;

this._dbc.Parameters.Add("v_account", OdbcType.VarChar, 70);
this._dbc.Parameters["v_account"].Value = account;
this._dbc.Parameters["v_account"].Direction = ParameterDirection.Input;

OdbcParameter op = this._dbc.Parameters.Add("@results", OdbcType.VarChar, 70);
op.Direction = ParameterDirection.Output;
execute_nonquery(this._dbc);
string results = (string)op.Value;

SHA1 sha = new SHA1CryptoServiceProvider();
byte[] buffer1 = new ASCIIEncoding().GetBytes(password);
byte[] buffer2 = sha.ComputeHash(buffer1);
sha.Clear();
return results == Convert.ToBase64String(buffer2) ? true : false;
}


private void execute_nonquery(OdbcCommand cmd) {
cmd.Connection = this._db;
this._db.Open();
try {
// test stored password with supplied password
cmd.ExecuteNonQuery();
} catch (Exception ex) {
// future error trapping
this._log.exception(ex.Message);
}
this._db.Close();
}
 
Assume that I have already taken care of that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top