Page 1 of 1

Enterprise Library 2.0 ConfigureParameter does not like DataRowVersion.Default

Posted: Wed 01 Mar 2006 19:00
by Guest
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)

DataRowVersion.Default

Posted: Thu 02 Mar 2006 09:17
by SecureGen
Please specify for what purpose would you like to use DataRowVersion.Default?

Posted: Thu 02 Mar 2006 15:42
by Guest
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

Posted: Thu 02 Mar 2006 16:01
by SecureGen
We cannot reproduce such behavior. Please make sure that db object has type MySqlDatabase. Does our demo project DataAccessQuickStart work properly in your system?

Posted: Tue 07 Mar 2006 05:22
by Guest
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 :wink: ).

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

      
    
The ent lib config tool produced the following:

Code: Select all

         
To get it working,
  • 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.
Thanks for your help

Posted: Tue 07 Mar 2006 11:06
by SecureGen
This is a documentation bug. It will be fixed in the next build.

Posted: Thu 04 May 2006 13:21
by Guest
SecureGen wrote:This is a documentation bug. It will be fixed in the next build.
Is the above documentation bug is fixed in Release 3.5?

Posted: Fri 05 May 2006 08:37
by December
Yes, it is fixed.