gpt4 book ai didi

nhibernate - nhibernate sql Express连接问题-错误:26-查找指定的服务器/实例时出错

转载 作者:行者123 更新时间:2023-12-05 01:36:20 25 4
gpt4 key购买 nike

我可以正常连接ado.net。但是,当我尝试连接nHibernate时出现以下错误。

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=xxxxx\SQLEXPRESS; Database=xxxxx; User ID=xxxxx; Password=xxxxx; Trusted_Connection=True</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>


服务器错误

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

全栈

[SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔值breakConnection)+4845255
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)+194
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,SqlInternalConnectionTds connHandler,布尔ignoreSniOpenTimeout,Int64 timerExpire,布尔加密,布尔trustServerCert,布尔IntegratedSecurity,SqlConnection owningObject)+4858557
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,Boolean ignoreSniOpenTimeout,Int64 timerExpire,SqlConnection owningObject)+90
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(字符串主机,字符串newPassword,布尔型redirectedUserInstance,SqlConnection owningObject,SqlConnectionString connectionOptions,Int64 timerStart)+342
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject,SqlConnectionString connectionOptions,String newPassword,Boolean redirectedUserInstance)+221
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,对象providerInfo,String newPassword,SqlConnection owningObject,布尔redirectedUserInstance)+189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,对象poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection)+185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection,DbConnectionPool池,DbConnectionOptions选项)+31
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)+433
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)+66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)+499
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)+65
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection externalConnection,DbConnectionFactory connectionFactory)+117
System.Data.SqlClient.SqlConnection.Open()+122
NHibernate.Connection.DriverConnectionProvider.GetConnection()+102
NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()+15
NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(方言,IConnectionHelper connectionHelper)+65
NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)+80
NHibernate.Impl.SessionFactoryImpl..ctor(配置cfg,IMapping映射,设置设置,EventListeners侦听器)+599
NHibernate.Cfg.Configuration.BuildSessionFactory()+87
D:\ dev \ MyProject \ XXX \ XXX.Domain \ Repositories \ NHibernateHelper.cs:23中的XXX.Domain.Repositories.NHibernateHelper.get_SessionFactory()
D:\ dev \ MyProject \ XXX \ XXX.Domain \ Repositories \ NHibernateHelper.cs:31中的XXX.Domain.Repositories.NHibernateHelper.OpenSession()
D:\ dev \ MyProject \ XXX \ XXX.Domain \ Repositories \ EntryRepository.cs:152中的XXX.Domain.Repositories.EntryRepository.GetCountByGmapId(Int32 gmapId)
D:\ dev \ MyProject \ XXX \ XXX.Controls \ Activity.ascx.cs中的XXX.Controls.Activity.BindRepeater(Int32 id):58
XXX.Controls.Activity.DropDownListMaps_SelectedIndexChanged(Object sender,EventArgs e)在D:\ dev \ MyProject \ XXX \ XXX.Controls \ Activity.ascx.cs:75
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)+111
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent()+134
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()+10
System.Web.UI.Page.RaiseChangedEvents()+165
System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+1485

最佳答案

http://www.connectionstrings.com/

Server=myServerAddress;Database=myDataBase;
User ID=myUsername;Password=myPassword;Trusted_Connection=False;


我会尝试设置 Trusted_Connection=False看看会发生什么。

通常,当我看到该错误时,是因为我的连接字符串不正确或数据库已关闭/无法访问,但是我确定还有其他潜在原因。

关于nhibernate - nhibernate sql Express连接问题-错误:26-查找指定的服务器/实例时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2605732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com