I can't connect Netezza with microsoft ODBC (VS 2013) - asp.net

I install netezza ODBC drivers and configure data sources(ODBC) in Adminitstrative tools by add user DSN as NZSQL.
Next I connect with Visual studio 2013 using DSN in Server Explorer, in Datasource I select Microsoft ODBC data source and data provider I select .Net framework data provider for ODBC. The connection test is successful and I copy connectionstring from connection string in server explorer and paste it in web.config:
<add name="cn" connectionString="Dsn=NZSQL;Driver={NetezzaSQL};uid=kbanke2e"/>
When I compile the error is:
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

I successfully managed to create a Netezza datasource in VS2013 by specifying the full connection string manually:
Driver={NetezzaSQL};server=a.b.c.d;port=5480;database=SYSTEM;uid=myname;password=mypwd;
The only problem I had was due to VS looking for the 32-bit driver (nsqlodbc.dll) in C:\Windows\SysWOW64. Initially I only had the 64-bit driver installed.

Related

SSMS is OK but Local IIS Cannot Connect to SQL Server

I'm getting the dreaded "A network-related or instance-specific error" error but only when attempting to connect from my local IIS server. IIS and SQL are both installed on the same machine.
SQL Server (EXPRESS) is running and the SQL Server Browser is also running. Client Protocols (Shared Memory, TCP/IP, and Named Pipes) are all enabled. I can connect and run queries via SSMS both locally and remotely using both Named Pipes and TCP using either Windows Authentication (My Account) or a SQL Server login.
Here is the connection string I am using in my web.config
Server=(local)\SQLEXPRESS;Database=MyDbName;User ID=MyUsername;Password=MyPassword"
Server=(local)\SQLEXPRESS;Database=MyDbName;Integrated Security=True;
Any recommendations are appreciated:
Win Server: 2016
IIS: 10.0.14393
SQL Server Express: 14.0.1
Solved: This was due to an additional connection string only used for Code Migration updates.

db2 connection failing after migrating from iis7.5 to iis8.5

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.

Can't access database from local server, but can from remote server

I've been trying to setup an SQL Server 2016 Express instance for my ASP.NET Core app. I've gotten it to a point where I can connect to the database with a dev version on my local development machine, but not with a published version on the server (that's also hosting the SQL Server Instance)
I'll call the local dev version the "dev server", and the remote published version the "real server". Both servers access the same SQL Server instance
On the dev server I connect without issues to the SQL server with the following connectionString in my appSettings.json
Data Source=10.50.70.50;Integrated Security=False;User ID=voetbal;Password=*******;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
When I try to connect from the real server I get the 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
On the remote machine I've tried the following connectionStrings in both appsettings.json and as an environment variable:
With IP:
Data Source=10.50.70.50;Integrated Security=False;User ID=voetbal;Password=*****;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
With localhost instead of IP:
Data Source=localhost;Integrated Security=False;User ID=voetbal;Password=*****;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
With Local Machine name:
Data Source=WIN-DMM50393I9A;Integrated Security=False;User ID=voetbal;Password=*****;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
With Local Machine name and SQL instance name:
Data Source=WIN-DMM50393I9A\MSSQLLOCALDB;Integrated Security=False;User ID=voetbal;Password=*****;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
As localdb:
Data Source=(localdb)\\MSSQLLOCALDB;Integrated Security=False;User ID=voetbal;Password=*****;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
Then I thought, maybe it should be "Server" instead of "Data Source", so I tried them all again with that substitution. Still the same error.
So something tells me the connection string is not the issue here. Whenever I search the internet for the error, I only find posts about people trying to connect to an actual LocalDB instance, and not an SQL Server Express Instance. And if my app was indeed trying to connect to a LocalDB instance, then why is my dev server working with the database?
I don't know what else I can do to troubleshoot this issue. Any ideas?
Are you sure you have the ConnectionString defined for both environments: DEV and Production, regarding appsettings.Development.json and appsettings.json?
Could you try to log the connection string value on the server:
string conectionString = Configuration.GetConnectionString("DefaultConnection");

Connecting SQL Server database to ASP.NET application release

I have an ASP.NET application using Entity Framework. I'm trying to release it on the hosting, but I get following errors:
[Win32Exception (0x80004005): The system cannot find the file specified]
[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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
I set the connection string as shown on the hosting website and created database. How should I configure this to get rid of this error?
Exception due to your web application is not able to connect SQLSERVER instance. Following are options to resolve the problem:
Check if your service is running up
Go to All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services
Check to make sure SQL Server service status is Running.
or
Open run command console(Windows + R) then type services.msc. You will all services in your system and check SqlServer (Sqlexpress) service is running mode.
Make sure your database engine is configured to accept remote connections
Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
Click on Surface Area Configuration for Services and Connections
Select the instance that is having a problem > Database Engine > Remote Connections
Enable local and remote connections
Restart instance using services.msc in run command window(discussed in #1)
Enable TCP/IP in SQL Server Configuration
Go to All Programs >> Microsoft SQL Server 2012 > Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP
Right Click on TCP/IP >> Click on Enable
Then restart the sqlserver service using services.msc in run command window(discussed in #1)
Lastly you need to check that it might be server firewall setting because sometimes firewall blocks incoming request from other servers. And also check you are providing correct connection string means username, password, server etc.
Thank You..
<connectionStrings>
<add name="conn2" connectionString="Data Source=192.?.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
</connectionStrings>
As you are able to connect from SQL SMS, try to connect with the same remote parameters from Server Explorer window in Visual Studio as well. Click "add connection" on "Data Connections": Add Connection in Server Explorer. After the connection being created, get the connection string from the properties window by right clicking on the connection object. Use this connection string in the hosted web.config file.

Remote connection to SQL Server - Asp.net MVC

I'm currently setting up a remote SQL Server. Made all steps regarding remote connection (as found on http://blog.citrix24.com/configure-sql-express-to-accept-remote-connections/).
Let's say my servers are :
WEB
SQL
I can connect from WEB, using SQL Server Management Studio, to my SQL Server using my connection string. Using the same connection string in my web.config does not work, keep getting error 26 - Error locating server.
Connection string:
Data Source=169.254.196.1,1433;Initial Catalog=MyDb;User ID=myuser;Password=mypassword
Any ideas?

Resources