Hiho...
I've a problem with the Jet-Driver.
Log4Net tells me that NHibernate could not find the Jet Driver.
Where do I have to fix this?
My Config:
Code:
// Enable the logging of NHibernate operations
log4net.Config.XmlConfigurator.Configure();
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionProvider,
"NHibernate.Connection.DriverConnectionProvider");
cfg.SetProperty(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass,
"NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
switch (dbType)
{
case 1://Access
cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.JetDriver.JetDialect");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.JetDriver.JetDriver");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathToDb + ";User-Id=admin;Password=;");
break;
case 2://Access 2007
break;
case 3://MSSQL
cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.MsSql2000Dialect");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, "connectionString");
break;
case 4://SqlCE
cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.MsSqlCeDialect");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.SqlServerCeDriver");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString,"Data Source=" + pathToDb );
break;
}
cfg.AddAssembly("Database");
MemoryStream stream = new MemoryStream();
////Ask NHibernate to use fields instead of Properties
NHibernate.Mapping.Attributes.HbmSerializer.Default.Validate = true; //Enable Validation
NHibernate.Mapping.Attributes.HbmSerializer.Default.HbmDefaultAccess = "field.camelcase-underscore";
// Gather information from this assembly (can also be done class by class)
NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize( stream,
System.Reflection.Assembly.GetExecutingAssembly() );
stream.Position = 0;
cfg.AddInputStream(stream); // Send the Mapping information to NHibernate Configuration
stream.Close();
new NHibernate.Tool.hbm2ddl.SchemaExport(cfg).Create(true, true);
_sessionFactory = cfg.BuildSessionFactory();
With SqlCE, everything went fine.
What is wrong here?