I have a classic ASP web application which connects to a DB2 database to read some data. i migrated the application from windows server 2008r2(IIS7.5) to 2012r2(IIS8.5) and the application is not able to establish a connection to the database. i get below error
ERROR [HY000] [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 ERROR [HY000] [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004
my web.config
<add key="DB2TDSNName" value="Driver={{IBM DB2 ODBC DRIVER}};DBALIAS=DB2T;Uid={0};Pwd={1};" />
i use the above ODBC connection to connect to the database. It is working fine in IIS7.5 but not IIS8.5. should i be doing anything different in 8.5?
Note: i added a system DSN in ODBC data source and the connection was successful, somehow the application hosted from IIS is not able to establish a connection.
i found out what the issue is. the environment variable for DB2 driver was not properly declared in System environment variables. i added it to the Path environment variables and it is working.
Related
I followed every instruction to publish and deploy my project into AZURE my web-app from Visual Studio and my SQL database from Microsoft SQL server management. It shows successful for everything and the web-app runs. The following error shows whenever any interaction happens with the database:
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: 26 - Error Locating Server/Instance Specified)?.
However, I did reconfigure the Connection string in the web-app before publishing it and the problem still showing. here is the connection string that I am using. and I got it from Azure using the same name of the database as it mentions.
Server=tcp:apuldb.database.windows.net,1433;Initial Catalog=apuldb;Persist Security Info=False;User ID=*****;Password=*****;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Update: the app fully works via the above connection string only when I run it from Visual Studio locally. So, the app can be connected successfully to the online database in the cloud if I run it locally using AZURE database.
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.
Tech used:
Visual Studio 2015
ASP.NET 5 MVC 6 RC1
Identity via EF 7
I've successfully made a connection to a remote MSSQL server using the Server Explorer UI within VS2015. When I say "remote", I mean not on the same machine as my dev machine, but a machine that is local to the network.
Here is the connection string, which is the same in the Server Explorer (works) and the appsettings.json (doesn't work):
"Data Source=DBSERVER\INSTANCE1;Initial Catalog=MyDb;User ID=ASPNET-Db-User;Password=thepassword"
I'm using SQL Authentication in both cases.
When I copy the connection string from the server explorer and plug it into appsettings.json and try to connect to the db in order to create an Identity user account via the "register account" view, I get a connection error:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"
It seems that, clearly, the SQL instance is reachable, but somehow ASP.NET isn't able to connect to it.
Any idea how I might trouble shoot this?
I tried the same code in MVC5 and everything works as expected. I believe this to be a MVC 6 error and have opened a bug report at
https://github.com/dotnet/corefx/issues/4586
After chatting with the folks building MVC 6, it turns out that the CoreCLR does not support named pipes. Using a fully qualified address and an explicit port sorts the problem.
I developed an ASP.NET web application and it worked fine locally with IIS express.
I created deployment package and installed the application on my Windows 2012 server.
When developing the application, I was using an mdf file with localdb v11.0. On the server, however, I wanted to use sqlserver express. I changed the connection string to
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\nameoffile.mdf;Integrated Security=True;Connect Timeout=30
After making this change I was able to connect to the application from another host on the network. Viewing data and using filters/search (built into stored procedures) works fine.
The error occurs when I try to insert new records or delete records. The message is:
Server Error in '/Nameofapplication' Application.
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. )
I've turned off the firewall, allowed remote connections, started sql server browser and agent and various other solutions that I've found from googling without any luck.
Any ideas about how to solve this issue?
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. :)