List:MySQL and .NET« Previous MessageNext Message »
From:Reggie Burnett Date:August 26 2005 1:40pm
Subject:RE: New problem with 1.0.5
View as plain text  
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
> 

Thread
New problem with 1.0.5Patrick Bennett26 Aug
RE: New problem with 1.0.5Reggie Burnett26 Aug
  • RE: [mysql] RE: New problem with 1.0.5Patrick Bennett26 Aug