Gentlemen, good evening.
Im trying to make a connection with my AS400 client (Windows) and my AS400 Server (unix), both V5R4M0, using IBM.DATA.DB2.Dll and IBM.DATA.DB2.iSeries.Dll.
The problem is, NHibernate uses IBM.DATA.DB2.iSeries DLL to make the connections...
But im experiencing the following message: "Unable to cast object of type 'IBM.Data.DB2.iSeries.iDB2Connection' to type 'System.Data.Common.DbConnection'.", When i call BuildSessionFactory (code below):
Code:
var cfg = new NHibernate.Cfg.Configuration();
//cfg.Configure();
cfg.DataBaseIntegration(
x =>
{
x.ConnectionString =
"UserID=CARVALHORA;DataSource=BRRIO04;Password=*****;LibraryList=BRSAP;Initial Catalog=BRSAP;Database=D103be2f";
x.Dialect<DB2400Dialect>();
x.Driver<DB2400Driver>();
});
var fluentConfig = Fluently.Configure(cfg)
.Mappings(
m =>
m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.BuildConfiguration();
_sessionFactory = fluentConfig.BuildSessionFactory();
Can you guys please, gimme a hand? Im working with .net 4.5 and NHibernate 3 with Fluent, all latest Versions...
Ive tried to connect directly thru the DLL (without NHibernate), and worked:
Code:
String sql = "SELECT * FROM BRSAP.MM_HEADER";
System.Data.IDbConnection connection = null;
IDataReader reader = null;
try
{
connection = new iDB2Connection("UserID=CARVALHORA;DataSource=BRRIO04;Password=******;LibraryList=BRSAP;Initial Catalog=BRSAP;Database=D103be2f");
connection.Open();
var x = (IDbConnection) connection;
IDbCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = sql;
reader = command.ExecuteReader();
}
finally
{
try { reader.Close(); }
catch (Exception ex) { }
try { connection.Close(); }
catch (Exception ex) { }
}
Thanks in advance.