Patrick
Can you give me a short snippet of code that shows the problem? Here is my
unit test for this.
[Test]
public void SetDbType()
{
try
{
IDbConnection conn2 = (IDbConnection)conn;
IDbCommand cmd = conn.CreateCommand();
IDbDataParameter prm = cmd.CreateParameter();
prm.DbType = DbType.Int32;
Assert.AreEqual(DbType.Int32, prm.DbType);
MySqlParameter p = new MySqlParameter("name", DbType.Int32);
Assert.AreEqual(DbType.Int32, p.DbType);
Assert.AreEqual(MySqlDbType.Int32, p.MySqlDbType);
p.Value = (object)3;
Assert.AreEqual(DbType.Int32, p.DbType);
Assert.AreEqual(MySqlDbType.Int32, p.MySqlDbType);
}
catch (Exception ex)
{
Assert.Fail( ex.Message );
}
}
> -----Original Message-----
> From: Patrick Bennett [mailto:patrick@stripped]
> Sent: Thursday, August 25, 2005 11:45 PM
> To: dotnet@stripped
> Subject: New problem with 1.0.5
>
> I've got a custom class that converts from my own 'SQL'
> datatype classes into SQLParameters - part of the code is
> something like this:
> if (obj is ISQLBindable)
> {
> MySqlParameter parm = new MySqlParameter( paramName, (obj
> as ISQLBindable).DbType());
> // For an object of my SQLInt type for example, DbType
> would return
> MySqlDbType.Int64
> // So, after the above call, the DbType and MySqlDbType
> of 'parm' is
> Int64
>
> // However... as soon as a value is set for the parameter
> (which worked in 1.0.4), then the DbType switches to Object
> and the MySqlDbType switches to Blob
> parm.Value = obj; // Presumably the appropriate
> IConvertible overload
> would've been called to get the value, but.. no
> cmd.Parameters.Add( parm );
> }
>
>
>
> // Once a query using this parameter is executed, I get the exception:
> Only byte arrays and strings can be serialized by MySqlBinary.
>
> Any ideas what's going on? Why did this behavior change, or
> what am I doing wrong?
>
> Thanks,
>
> Patrick Bennett
>
>
>
>
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:
> http://lists.mysql.com/dotnet?unsub=1
>