Enterprise Library 2.0 ConfigureParameter does not like DataRowVersion.Default
Enterprise Library 2.0 ConfigureParameter does not like DataRowVersion.Default
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)
DataRowVersion.Default
Please specify for what purpose would you like to use DataRowVersion.Default?
Actually, I don't want to use sourcecolumn and sourceversion, at all. But I have to set those parameters in order for MySQLDirect to complete the AddInParameter method. If it's not specified, then EntLib 2.0 uses DataRowVersion.Default as the sourceversion.
When I try the following code with the Ent Lib 2.0, I get the error.
db.AddInParameter(dbCommand, "MyParameter", DbType.String, "MyString")
When I debug the error, it's happening because the EntLib code is setting the sourceversion to DataRowVersion.Default if it's not specified. At this point, MySQLDirect.Net throws the invalid operation exception...
Thanks
David
When I try the following code with the Ent Lib 2.0, I get the error.
db.AddInParameter(dbCommand, "MyParameter", DbType.String, "MyString")
When I debug the error, it's happening because the EntLib code is setting the sourceversion to DataRowVersion.Default if it's not specified. At this point, MySQLDirect.Net throws the invalid operation exception...
Thanks
David
You were right - I had used the ent lib config tool and picked "CoreLab.MySQL" as the type.
I was able to get it working by actually following the directions in the documentation (imagine that ).
However, using the delivered CoreLab.EnterpriseLibrary.Data.MySql.dll and the example provider mapping in the documentation I was not able to get it working. The documentation shows
The ent lib config tool produced the following:
To get it working,
I was able to get it working by actually following the directions in the documentation (imagine that ).
However, using the delivered CoreLab.EnterpriseLibrary.Data.MySql.dll and the example provider mapping in the documentation I was not able to get it working. The documentation shows
Code: Select all
Code: Select all
- I compiled the CoreLab.EnterpriseLibrary.Data.MySql.dll
- used the ent lib config to generate the provider mapping by loading the assembly
- manually editted the web.config to use the provider name (you can't pick it from the list in the ent lib config tool.