无法从asp.net中的web.config连接数据库 [英] Not able to connect Database from web.config in asp.net

查看:63
本文介绍了无法从asp.net中的web.config连接数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我无法使用web.config中的连接字符串连接到数据库,请帮助我,我收到此类型的错误页面,请帮助我如何使用SQL Server的用户名和密码在web.config中编写连接字符串


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


说明:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息.

异常详细信息:System.Data.SqlClient.SqlException:建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接. (提供者:命名管道提供者,错误:40-无法打开与SQL Server的连接)



谢谢
< big&s; sudheer.N</big>

Hi All,


i am not able to connect to database using connection string in web.config please help me , i am getting this type of error page, please help me how to write connection string in web.config using userid and password of my sql server


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)



Thanks
<big>sudheer.N</big>

推荐答案

基本上,当您无法连接到SQL Server时,问题可能是:
1)网络问题,
2)SQL Server配置问题.
3)防火墙问题,
4)客户端驱动程序问题,
5)应用程序配置问题.
6)身份验证和登录问题.

Basically, when you failed to connect to your SQL Server, the issue could be:
1) Network issue,
2) SQL Server configuration issue.
3) Firewall issue,
4) Client driver issue,
5) Application configuration issue.
6) Authentication and logon issue.

检查这些
解决SQL连接问题的步骤 [ ^ ]
SQL Server 2005连接性问题疑难解答-第一部分 [对SQL Server 2005中的连接问题进行故障排除-第二部分 [ ^ ]
对SQL Server 2005中的连接问题进行故障排除-第III部分 [ ^ ]

顺便说一句,也检查这堆是否有将来的错误

Check these
Steps to troubleshoot SQL connectivity issues[^]
SQL Server 2005 Connectivity Issue Troubleshoot - Part I[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part II[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part III[^]

BTW check this bunch also for future errors


嗨苏德海尔,

希望对您有帮助

Hi Sudheer,

hope this will help u

<connectionStrings>
        <add name="Default" connectionString="Data Source=Ur server IP;User Id=sa;password=sa;Initial Catalog=UR DB Name />   </connectionStrings>




问候,
Sucharitha




Regards,
Sucharitha


嗨苏德海尔,

一些检查清单

1.使用SQL Server配置管理器检查您的SQL Server是否暴露于tcp/ip协议.
2.检查连接字符串的格式

Hi Sudheer,

Some check list

1. Check that your SQL server is exposed to tcp/ip protocol using SQL Server Configuration Manager.
2. Check the format of your connection string

<add connectionstring="Server=<Server Name>;User ID=<User Name>;Password=<Password>;Database=<DatabaseName>" name="<ConnectionStringName>" />



3.检查您的SQL Server是否使用混合模式进行身份验证.

谢谢
Vinod



3. Check that your SQL Server is using mixed mode for the authentication.

Thanks
Vinod


这篇关于无法从asp.net中的web.config连接数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆