NHibernate 连接 Access数据库配置
中间层代码:
web.config 中配置如下
private static readonly NHibernate.Cfg.Configuration configuration;
configuration = new Configuration().Configure();
string connection_string = configuration.GetProperty("hibernate.connection.connection_string");
connection_string = connection_string.Replace("|ServerDirectory|", HttpContext.Current.Request.MapPath("~"));
configuration.SetProperty("hibernate.connection.connection_string", connection_string);
configuration.SetProperty("connection.connection_string", connection_string);
sessionFactory = configuration.BuildSessionFactory();
configuration = new Configuration().Configure();
string connection_string = configuration.GetProperty("hibernate.connection.connection_string");
connection_string = connection_string.Replace("|ServerDirectory|", HttpContext.Current.Request.MapPath("~"));
configuration.SetProperty("hibernate.connection.connection_string", connection_string);
configuration.SetProperty("connection.connection_string", connection_string);
sessionFactory = configuration.BuildSessionFactory();
web.config 中配置如下
<property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|ServerDirectory|\\App_Data\\Sample.mdb</property>
邮箱 tickup [{at}] QQ.COM