设置提供程序时出错

设置提供程序时出错

问题描述:


 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)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


web.config


web.config

检查是否已安装SQL Server,并且可以访问它. 如果可以,那么可以在连接代码周围放置一个try ... catch块,并检查异常和内部异常.检查名称.
通过编辑您的原始问题来报告发现,并在此答案中添加评论,以便让我收到更多信息.
Check you have SQL server installed, and you can access it.
If you do, and you can, then put a try...catch block around the connection code, and examine the exception and inner exception. Check names.
Report findings by editing your original question, and add a comment to this answer, so I am alerted you have more info.


<?xml version="1.0"?>
<configuration>
 <configSections>
 <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
 ... <!-- код студии -->
</sectionGroup>
 </sectionGroup>
 </configSections>
 <appSettings/>
 <connectionStrings>
 <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
 </connectionStrings>
 <system.web>
 <authentication mode="Forms">
 <forms loginUrl="login.aspx"

 name=".ASPXFORMSAUTH" />
 </authentication>
 <roleManager enabled="true" />
 <compilation debug="true">
...
 </compilation>
 <pages>
 <controls>
 ... </pages>
 <httpHandlers>
...
 <httpModules>
 ... </httpModules>
 <membership defaultProvider="SqlProvider"

 userIsOnlineTimeWindow="15">
 <providers>
 <add

 name="SqlProvider"

 type="System.Web.Security.SqlMembershipProvider"

 connectionStringName="SqlServices"

 applicationName="MyApplication"

 enablePasswordRetrieval="false"

 enablePasswordReset="true"

 requiresQuestionAndAnswer="true"

 requiresUniqueEmail="false"

 passwordFormat="Hashed"

 maxInvalidPasswordAttempts="5"

 passwordAttemptWindow="10" />
 </providers>
 </membership>

 </system.web>
 <system.codedom>
 <compilers>
 <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
 ... </compiler>
 </compilers>
 </system.codedom>
 <system.webServer>
 <validation validateIntegratedModeConfiguration="false"/>
 <modules>
 <remove name="ScriptModule"/>
 <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
 </modules>
 <handlers>
 ...
 </handlers>
 </system.webServer>
 <runtime>
 ...
 </runtime>
</configuration>


上面列出的文件web.konfig
也许写错了.
该数据库是通过ASP.NET密码创建的. 该数据库位于文件夹App_Data中.
默认情况下,所有原则上都是如此.
当组件ID登录并输入密码时,此错误
The above listed file web.konfig
Perhaps it is wrong written.
The database was created through the ASP.NET konfiguration
The database is in the folder App_Data.
All in principle by default.
When a component ID login and password, this error