Cannot connect to SystemDSN ODBC datasource IIS 7 - iis-7

I have configured odbc datasource as System DSN.
It works fine by itself and from Visual studio.
When I try to start applicattion under the IIS 7 on connection I get an error:
ERROR [08001] [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [5].
ERROR [HYT00] [Microsoft][SQL Server Native Client 10.0]Login timeout
expired
ERROR [08001] [Microsoft][SQL Server Native Client 10.0]A
network-related or instance-specific error has occurred while
establishing a connection to SQL Server. Server is not found or not
accessible. Check if instance name is correct and if SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online.

IIS Application runs as different user - this user has no access premonitions to somewhere that ODBC uses.
I changed ApplicationPool identity to ran as administrator - this solved my problem. This was the fast solution. At least this is dirrection to dig. :)

Related

.NET Core API cannot connect to MS LocalDB

I am writing a .NET Core 2.1 web API using MS LocalDB. I can connect to my DB fine using SSMS and the server name (localdb)\MSSQLLocalDB with Windows Authentication.
The API fails to connect with the error:
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: SQL
Network Interfaces, error: 50 - Local Database Runtime error occurred.
Cannot create an automatic instance. See the Windows Application event
log for error details.
My connection string is:
Server=(localdb)\\MSSQLLocalDB;Database=Foo;Trusted_Connection=True;MultipleActiveResultSets=true
As a side note, I tried to check my LocalDB version with sqllocaldb v but got the following error:
Windows API call "RegGetValueW" returned error code: 0.
Is my LocalDB installation completely borked?
its kinda late but i am trying this for 2 days and finally found the answer.
When app is running on IIS
--> go to advance setting in the application pool, then on change "Process Model->Load Profile" to TRUE;
when app is running on Kestrel,
a. connection string "Data Source=(localdb)\mssqllocaldb"... etc
hope this help the others.

Connection issue between Asp.Net 4.5 app and SQL Server 2012

I have a web forms application that is connecting to a SQL Server 2012 database. When I try to open the connection within the app I get this error:
System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) ---> ...
I've checked and SQL server is configured to allow remote connections, TCP/IP is enabled, the server is up and I can connect to it via SSMS and Linqpad.
This is occurring when I run the application locally, hitting a local database. I know the connection string works, as I can use the login in SSMS to login and I have a linqpad query that is working with no problem using the same connection string. Also the error occurs when I try to open the connection (i.e. the connection is created successfully).
I'm guessing there is some access/security issues with my configuration of IIS, but I not finding it.
After a couple of frustrating days, I discovered the solution. The problem was that SQL server wasn't setup to use TCP/IP. This is configured in the Sql Server Configuration Manager, under the SQL Serer Network Configuration node, then Protocols for MSSQLSERVER. Make sure TCP/IP is enabled.

DB Connection ERROR after publishing the web application in IIS 6

After publishing web application in IIS 6 I am getting follwoing error
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)
It runs fine in development server with same DB connection
Please help me
there can be multiple issues with this. But basic problem is that web server is not able to locate DB server.
Try below steps to figure out the exact issue
is the DB server pingable from your web server?
are you providing correct user while connecting to SQL server.
are you able to connect to the DB server from web server using the username you provided in your config file?
try all above and let me know your result.

getting error while connecting microsoft sql server

I had installed Microsoft SQL Server Management Studio Express.But after installation when i connect the SQL server I am getting the following error.
TITLE: Connect to Server
Cannot connect to S-PC.
ADDITIONAL INFORMATION:
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) (Microsoft SQL Server, Error: 2)
Please suggest me something to remove this error.
It looks as if the service is not running. Run Services.msc, find SQL Server (MSSQLSERVER) in the services list and click on Start Service button.

Unable to Connect to SQL Server Database using ASP.NET Webservice

I have a website and a webservice. Both uses same Data Access Layer. Both uses same connection string to connect to SQL Server 2008. But my website is able to connect to the database but webservice throws following exception:
Server was unable to process request. ---> System.Exception: System.Exception: 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.
Other then verifying the connection string/network level stuff, is there any "out of the box" error that might cause this issue?
Database: SQL Server 2008
OS: Windows Server 2008 R2
.NET Framework: 2.0
I'm guessing the web server and DB server are on two different boxed. First ensure that external connections are permitted by the SQL server, then ensure that the port is open between the two server (you can do this using telnet).

Resources