You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by Ron Grabowski <ro...@yahoo.com> on 2006/08/10 06:13:33 UTC
IBatisNet can't set SqlCommand's Connection property under Mono
I was experimenting with this Mono VMWare image:
http://www.mono-project.com/news/archive/2006/Jul-28.html
by making a very very simple ConsoleApplication with one sql map
containing this statement:
SELECT * FROM Product WHERE ProductId = #value#
I encountered this exception:
Unhandled Exception:
IBatisNet.Common.Exceptions.ConfigurationException:
- The error occured while Validate SqlMap.config.
- Check the parameter mapping typeHandler attribute '' (must by a
ITypeHandlerCallback implementation).
- The error occured in <sqlMap embedded="Resources.Product.xml,
ConsoleApplication2" xmlns="http://ibatis.apache.org/dataMapper" />.
- Check the Product.GetMany. --> System.InvalidCastException: The value
was not a valid SqlConnection.
at
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.set_Connection
(IDbConnection value) [0x00000]
at IBatisNet.DataMapper.SqlMapSession.CreateCommand(CommandType
commandType) [0x00000]
at
IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory.CreateParametersForTextCommand()
[0x00000]
The code works correctly on Microsoft.NET.
Here's a link to Mono's SqlCommand.cs:
http://tinyurl.com/enb3a
http://svn.myrealbox.com/viewcvs/trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs?rev=62561&view=log
Is this something we can fix or work around?
Re: IBatisNet can't set SqlCommand's Connection property under Mono
Posted by Ron Grabowski <ro...@yahoo.com>.
Changing the code in SqlMapSession.CreateCommand() from this:
IDbCommand command = _dataSource.DbProvider.CreateCommand();
command.CommandType = commandType;
command.Connection = _connection;
to this:
SqlCommand command =
(SqlCommand)_dataSource.DbProvider.CreateCommand();
command.CommandType = commandType;
command.Connection = _connection;
solved the problem. I want to use IDbCommand and not SqlCommand.
--- Gilles Bayon <ib...@gmail.com> wrote:
> Its seems that the set connection on SqlCommand attend a
> SqlConnection and
> that a IDbConnection wa passed which cause the cast exception. You
> should
> check your provider..
>
Re: IBatisNet can't set SqlCommand's Connection property under Mono
Posted by Gilles Bayon <ib...@gmail.com>.
Its seems that the set connection on SqlCommand attend a SqlConnection and
that a IDbConnection wa passed which cause the cast exception. You should
check your provider..