1
Vote

DbParamter can't be converted to MySqlParamter

description

Changeset 15876
 
In function PopulateType(DbParameter dbParameter, AdoDbType type) why is the dbParamter trying to be cast as a MySqlParameter to get the DbType? In function PopulateValue(DbParameter dbParameter, object value) it doesn't do this conversion. I am getting the error that dbParameter can't be converted to MySqlParameter and so the function throws an exception.

comments

AlexanderYao wrote Jul 15, 2009 at 3:13 AM

I've encountered similar problem that DbParameter can't be converted to OracleParameter, and the WFTools samples solution can't be compiled.

Looking for answers too...

ksteenkamp wrote Aug 28, 2009 at 11:27 AM

Hi,

I too got this error. I am using MySql.
WFTools seems to be very work in progress... this might fix your problem...
Guid is not spported in mySQL and the offending method is meant to convert an incoming guid type to a string.

In the WFTools.Services.MySql poject, MySqlResourceProvider overrides DefaultAdoResourceProvider

I modified the code and recompiled the WFTools.Services.MySql assembly.

OLD:
    protected override void PopulateType(DbParameter dbParameter, AdoDbType type)
    {
        MySqlParameter mySqlParameter = dbParameter as MySqlParameter;
        if (mySqlParameter == null)
            throw new ArgumentException(RM.Get_Error_MySqlParameterExpected());

        if (type == AdoDbType.Guid)
            mySqlParameter.DbType = DbType.String;
    }

NEW: (note I call base method as well, previous method seems to do nothing???)
    protected override void PopulateType(DbParameter dbParameter, AdoDbType type)
    {
        if (type == AdoDbType.Guid)
            dbParameter.DbType = DbType.String;
        else
            base.PopulateType(dbParameter, type);
    }
The problem went away, but the workflow doesnt seem to be persisting.

ksteenkamp wrote Aug 28, 2009 at 11:38 AM

Sorry...
        if (type == AdoDbType.Guid)
        {
            base.PopulateType(dbParameter, AdoDbType.String);
        }
        else
        {
            base.PopulateType(dbParameter, type);                
        }

wrote Feb 13, 2013 at 8:53 PM