Enterprise Library 2.0 ConfigureParameter does not like DataRowVersion.Default
Posted: Wed 01 Mar 2006 19:00
I get an InvalidOperationException exception whenever I try to use db.AddInParameter when the SourceVersion is not specified.
When not specified, it gets set to DataRowVersion.Default which gives an exception (see below).
Explicitly setting it to DataRowVersion.Current will work.
So I'm working around by
db.AddInParameter(dbCommand, "MyParameter", DbType.String, "", DataRowVersion.Current)
db.SetParameterValue(dbCommand, "MyParameter", "MyValue")
Full Exception is:
System.InvalidOperationException was unhandled by user code
Message="The DataRowVersion enumeration value, Default, is invalid."
Source="CoreLab.MySql"
StackTrace:
at CoreLab.Common.DbParameterBase.set_SourceVersion(DataRowVersion value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.ConfigureParameter(DbParameter param, String name, DbType dbType, Int32 size, ParameterDirection direction, Boolean nullable, Byte precision, Byte scale, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateParameter(String name, DbType dbType, Int32 size, ParameterDirection direction, Boolean nullable, Byte precision, Byte scale, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.AddParameter(DbCommand command, String name, DbType dbType, Int32 size, ParameterDirection direction, Boolean nullable, Byte precision, Byte scale, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.AddParameter(DbCommand command, String name, DbType dbType, ParameterDirection direction, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.AddInParameter(DbCommand command, String name, DbType dbType, Object value)
at _Default.GetUserID(String UserName, String Password) in C:\Temp\MySQLTest\Default.aspx.vb:line 21
at _Default.Page_Load(Object sender, EventArgs e) in C:\Temp\MySQLTest\Default.aspx.vb:line 37
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
When not specified, it gets set to DataRowVersion.Default which gives an exception (see below).
Explicitly setting it to DataRowVersion.Current will work.
So I'm working around by
db.AddInParameter(dbCommand, "MyParameter", DbType.String, "", DataRowVersion.Current)
db.SetParameterValue(dbCommand, "MyParameter", "MyValue")
Full Exception is:
System.InvalidOperationException was unhandled by user code
Message="The DataRowVersion enumeration value, Default, is invalid."
Source="CoreLab.MySql"
StackTrace:
at CoreLab.Common.DbParameterBase.set_SourceVersion(DataRowVersion value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.ConfigureParameter(DbParameter param, String name, DbType dbType, Int32 size, ParameterDirection direction, Boolean nullable, Byte precision, Byte scale, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateParameter(String name, DbType dbType, Int32 size, ParameterDirection direction, Boolean nullable, Byte precision, Byte scale, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.AddParameter(DbCommand command, String name, DbType dbType, Int32 size, ParameterDirection direction, Boolean nullable, Byte precision, Byte scale, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.AddParameter(DbCommand command, String name, DbType dbType, ParameterDirection direction, String sourceColumn, DataRowVersion sourceVersion, Object value)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.AddInParameter(DbCommand command, String name, DbType dbType, Object value)
at _Default.GetUserID(String UserName, String Password) in C:\Temp\MySQLTest\Default.aspx.vb:line 21
at _Default.Page_Load(Object sender, EventArgs e) in C:\Temp\MySQLTest\Default.aspx.vb:line 37
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)