Accessing procedure parameters with Oracle Odp database block
April 21st, 2008
The particularly astute among you will have noticed that we have been accessing parameters directly in the code I posted. Really we should be using the Set and Get methods that the database object provides. So instead of:
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCmd = db.GetStoredProcCommand("AUTH_LOGIN");
db.DiscoverParameters(dbCmd);
DbParameterCollection cmdParams = dbCmd.Parameters;
cmdParams["P_OSNAME"].Value = criteria.Username;
cmdParams["P_INCOMING_PASSWORD"].Value = criteria.Password;
db.ExecuteNonQuery(dbCmd);
authenticationReturnCode =
Convert.ToInt32(db.GetParameterValue(dbCmd, "P_RET_CODE"));
do
db.SetParameterValue(dbCmd, "P_OSNAME", criteria.Username);
and
authenticationReturnCode = db.GetParameterValue(dbCmd, "P_OSNAME");
I strongly advise you do do this - a lot of my pain over the last few days would have been eased if I had.
Posted in Development |
Comments
Leave a Reply
You must be logged in to post a comment.