Archive for the ‘Development’ Category
What’s a dev to do?
Monday, July 7th, 2008
I have been trying to get straight in my head what I want to become proficient at in order to be a useful software developer for the next three years. It’s proving really difficult. I’ve always felt that, as a professional working every day cranking out code for real clients on real projects, it is very difficult to keep up with what keeps falling out of Microsoft. I have to say I don’t think they do that good a job in helping us committed and loyal Microsofties do that, especially those of us who haven’t the time or money to attend conferences, or don’t live in the M4 corridor (UK specific reference there).
Here’s my (unfinished) list:
Things that are a given - that I need to know
Silverlight
ASP.Net latest version
The side-road stuff that I think will make a difference:
CSLA latest version
AJAX for ASP (although I hope that using a UI toolkit like Telerik or Infragistics may allow me to enter a layer up the stack)
Code generation - I’ve been keen on this for ages but never found a practical implementation I liked, but more on this soon.
WPF/Acropolis/Prism - having used the WinForms CAB I wan’t to get my head around the latest generation stuff for the desktop.
Posted in Development | No Comments »
Accessing procedure parameters with Oracle Odp database block
Monday, 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 | No Comments »
EntLib Data Access block with Oracle Odp OUT parameters
Friday, April 18th, 2008
My code has been failing when getting values out of procedures when I switch from the Microsoft provider to the Odp provider inside the Data Access App Block.
Here is some typical code:
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"));
This doesn’t work - it fails with an exception:
Unable to cast object of type ‘Oracle.DataAccess.Types.OracleDecimal’ to type ‘System.IConvertible’.
P_RET_CODE is defined as a NUMBER OUT in the procedure.
It seems that the DiscoverParameters call doesn’t set up the OUT parameter quite right, even though it looks fine. However, if you explicitly tell it the expected data type it decides to work (this line comes just before the ExecuteNonQuery):
cmdParams["P_RET_CODE"].DbType = System.Data.DbType.Decimal;
Posted in Development | No Comments »
Adapting the DAAB to use Oracle ODP.Net provider
Tuesday, April 15th, 2008
I’ve been doing a bit of tweaking of the Data Access Application Block to try and get around the problem described earlier.
I’ve replicated OracleDatabase, OracleDataReaderWrapper and the OracleDatabaseAssembler to reference the Odp provider (Oracle.DataAccess) rather than System.Data.OracleClient. I’ve called these classes OracleOdpDatabase etc. Inside them are some simple changes to enumeration values and data types (details on request).
Then a simple addition to the configuration details makes the block use the new objects rather than the old ones:
You need to add a providerMappings section inside the <dataConfiguration defaultDatabase="Dev" > section to indicate what new database class to use
<providermappings>
<add
databaseType= "Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleOdpDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
name="Oracle.DataAccess.Client" >
<providermappings>
Note that I haven’t ramped the version number here which I suspect I should if I end up using this in production.
Then in the connectionStrings section just reference the Odp provider:
<add name="Dev" connectionString="Data Source=dev;User ID=owner;Password=owner;" providerName="Oracle.DataAccess.Client" />
The ODP provider doesn’t recognise the Unicode item in the connection string that I have been using with the Microsoft provider.
This mostly works but I am having problems getting return values from procedures with OUT parameters. More details to follow…
Posted in Development | No Comments »
Oracle CLOB’s and the MS Data Access Application Block
Wednesday, April 9th, 2008
We have hit upon a problem with the Microsoft Data Access Application Block when trying to update / insert to an Oracle CLOB column; in short it doesn’t work.
In long: it seems to work until the total size of the data you are passing to the procedure is over ~32k. This actually seems to be a limitation of the System.Data.Oracle provider rather than anything the DAAB is doing.
Posted in Development | No Comments »
Preventing the designer setting properties of a User Control
Wednesday, July 4th, 2007
I’ve built a couple of user controls to simplify some data capture in our current application, one of which is a date choosing control. It exposes a couple of fields exposed as properties that should only be used by code and not accessible through the design-time property grid. I quickly discovered the decoration [Browsable(false)] to stop the property from showing up in the Properties grid, but the designer was still setting them in InitializeComponent; until I discovered the power of [DesignerSerializationVisibility].
Decorating the property with [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] supresses the serialization of the value into the designer code. There are two other options - Visible which only serializes the value if it isn’t the default (and you can use the DefaultValue to set that) and Content which does something clever with collection properties.
Aren’t attributes great!
Posted in Development | No Comments »
Finding the deepest node in some XML using XPath
Tuesday, August 22nd, 2006
Today’s problem was, given a set of XML nodes or arbitrary depth, how do I find the deepest node quickly. I have an XML description of a hierarchy of folders in a document respository. It consists of a series of Location elements, each with one or more children.
After quite a bit of pootling around using XPath, I came up with this…
XmlNodeList deepestNodes = _routingInfo.SelectNodes(”//Location[count(child::*)=0]“);
That is (I think) an instruction to select all nodes called Location that have zero children. Now all I need is to find which of these is the deepest.
Also, thanks to http://www.dpawson.co.uk/xsl/sect2/sect21.html which pointed me in the right direction.
Posted in Development | No Comments »