Professional Documents
Culture Documents
netCodeProject
Ask a Question All Unanswered FAQ
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 networkrelated or instancespecific error occurred while establishing a connection to SQL Server. The Top Experts
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 Last 24hrs This month
a connection to SQL Server
OriginalGriff 194 OriginalGriff 4,060
Also Read
Thanks
<big>sudheer.N</big>
Free OCR SDKs vs Paid OCR
SDKs
Add a Solution
Comments
From link[^]:
Basically, when you failed to connect to your SQL Server, the issue could be:
1 Network issue,
2 SQL Server configuration issue.
http://www.codeproject.com/Questions/304127/NotabletoconnectDatabasefromwebconfiginas 1/5
6/12/2016 NotabletoconnectDatabasefromweb.configinasp.netCodeProject
3 Firewall issue,
4 Client driver issue,
5 Application configuration issue.
6 Authentication and logon issue.
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[^]
Comments
Hi Sudheer,
Regards,
Sucharitha
Comments
thanks for your solution , but now also i am not able to connect it shows some error
could you please send me connection string and how to access that in c#.net
i use in web.config
it show error like error: 40 Could not open a connection to SQL Server
please help me sucharitha
Hi Sudheer,
http://www.codeproject.com/Questions/304127/NotabletoconnectDatabasefromwebconfiginas 2/5
6/12/2016 NotabletoconnectDatabasefromweb.configinasp.netCodeProject
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
3. Check that your SQL Server is using mixed mode for the authentication.
Thanks
Vinod
Comments
<AppSetting>
<add key="SqlConnectionString" value="Data
Source=ServerName;DataBase=DatabaseNAme;UID=sa;PWD=pass;Min Pool Size=10; Max Pool
Size=100"/>
</AppSetting>
check your name which you are enter.
Try this
Solution 1 :
If your SQL server is SQL Server Authentication then just use following Connectionstring
<AppSetting>
<add key=Connectionstring; value="Data
Source=ServerName;DataBase=DatabaseName;UserId=sa;Password=sa">
</AppSetting>
using System.Configuration;
string str = ConfigurationManager.AppSettings["Connectionstring"];
http://www.codeproject.com/Questions/304127/NotabletoconnectDatabasefromwebconfiginas 3/5
6/12/2016 NotabletoconnectDatabasefromweb.configinasp.netCodeProject
Solution 2 :
If your SQL server is Windows Authentication then just use following Connectionstring
<AppSetting>
<add key=Connectionstring; value="Data Source=ServerName;DataBase=DatabaseName;Integrated
Security=false">
</AppSetting>
using System.Configuration;
string str = ConfigurationManager.AppSettings["Connectionstring"];
B I U S small BIG code var < > & link [^] encode untab case indent outdent
Preview
2. Understand that English isn't everyone's first language so be lenient of bad spelling and
grammar.
3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question
and fix the problem. Insults are not welcome.
http://www.codeproject.com/Questions/304127/NotabletoconnectDatabasefromwebconfiginas 4/5
6/12/2016 NotabletoconnectDatabasefromweb.configinasp.netCodeProject
This content, along with any associated source code and files, is licensed under The Code Project Open
License CPOL
CodeProject, 503250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 4168498900 x 100
http://www.codeproject.com/Questions/304127/NotabletoconnectDatabasefromwebconfiginas 5/5