29 Feb 2004
14 Mar 2006
Link to this post
I have stumbled across a change in the Database class. With the addition of Oracle as a DB option, I guess there were changes made to the CreateParameter method in order to support the new DB. In the older version, you would pass in your IDbCommand, the parameter name in your sql statement with the "@" character as a prefix, and the parameter value. In the new version of the method, you must leave off the "@" character when passing in the parameter name.
string commandText = "Select * from table where Name = @Name";
using (Database db = dbFactory.CreateDatabase())
IDbCommand command = db.NewCommand(commandText );
db.CreateParameter(command, "@Name", "Name"); (Old Way)
db.CreateParameter(command, "Name", "Name"); (New Way)command.ExecuteNonQuery();
Although this is a minor change, it can cause some serious headaches when trying to use code written in v2.0 controls and trying to insert them into your v2.5 site. I hope this can help someone from hours of frustration when their controls won't work when upgrading to v2.5.