NHibernate有时候会出现连接不上数据库 10

出错:NHibernate.ADOException:cannotopenconnection--->System.Data.SqlClient.SqlException... 出错:NHibernate.ADOException: cannot open connection ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception: 拒绝访问。 展开
 我来答
司马刀剑
高粉答主

2017-10-12 · 每个回答都超有意思的
知道顶级答主
回答量:4.6万
采纳率:93%
帮助的人:8267万
展开全部
NHibernate各种数据库连接参数文件配置方法说明
//配置文件Config/Hibernate.cfg.xml内容如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="CwfServer">
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.connection_string">server=192.168.1.244;database=wf_db_t;uid=sa;pwd=supersit.1;</property>
<property name="adonet.batch_size">10</property>
<property name="show_sql">true</property>
<property name="command_timeout">60</property>
<property name="hbm2ddl.auto">update</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<!--<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>-->
<mapping assembly="Net.NHibernateDB"/>
<mapping assembly="Cwfapi"/>
<mapping assembly="CwfEngine"/>
</session-factory>
</hibernate-configuration>
追问

我这个代码和你的差不多,就是不懂为什么偶尔会提示连接不上

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式