Intermittent ODBC connection failures

北战南征 提交于 2019-12-17 10:07:24

问题


We are developing an in-house 32bit app. The app connects to a SQL Server. The test environment is SQL Server 2008 R2, and the live environment is SQL Server 2014 SP2.

Connection to the database is made using this ODBC string:

Driver={SQL Server};Server=<redacted>;Database=<redacted>;Trusted_Connection=Yes;

The users for this database belong to a 'domain local' security group. We have users from three different AD domains as members of this group. The group is defined as a login for the SQL Server and a user for the target database. In the test environment, this worked fine.

In the live environment, only some of the users can successfully connect to the database. Interestingly, users who are in the security group but NOT in the same domain as the server can connect. Users in the same domain as the server cannot. (I've not checked with all 25 users, but that's the pattern I'm seeing). Users (like me) with sysadmin rights to the database server have no trouble.

I've been over everything I can think of with a fine tooth comb trying to figure out why it works on one server but not the other, with no luck. I've tried removing the group as a user & adding back, taking users out of the group and putting them back in, and so forth. The SQL Server service is running under the same domain account on both servers.

Any insight is appreciated.


回答1:


I've had numerous issues with this in the past and the following worked:

  1. Navigate to Start | Microsoft SQL Server 2014 | SQL Server 2014 Configuration Manager.

Expand SQL Server Network Configuration, then click on the 2008 instance. Upon doing that, on your right, you will notice Shared Memory, Named Pipes and TCP/IP. Open Named Pipes and Enable it, if it's disabled. Open TCP/IP and enable it, but on TCP/IP, you will also notice a secondary tab called IP Addresses. Click on this tab and enable each IP Address individually for all IP Addresses (or only the ones you want to activate). You will also note that there is a TCP Port of which the default port for SQL is 1433. However, when you have more than one instance of SQL installed on the same machine, I usually split the port numbers. i.e. the one instance, I set to 1433 and the second, I set to 1435. See screenshot below:

Notice that I removed the zero in the TCP Dynamic Ports.

When you get to the end, set it like the following screenshot:

When you finished setting all this up, click on Apply, OK and then OK.

  1. Navigate to Start | Run.

Type in cliconfg (You'll have to do this on each machine that has issues connecting), then click OK.

Enable Named Pipes and TCP/IP, then tick the option Enable Shared Memory Protocol as can be seen below:

Click on Apply and then OK.

  1. Navigate to Start Run, type in services.msc, then click OK.

Navigate to both instances of SQL Server and restart them.

Also open SQL Server Browser, change it from Disabled to Automatic, then type in your AD Username & Password.

Click on Apply and OK, then start the Browser.

If you still have connection issues after this, try disabling Windows Firewall's or adding Port Exceptions as mentioned earlier in the answer.

If you still have issues, reply to this answer and I will assist you further...

Edit:

On the workstations, click on Start | Run, then type in cliconfg and click OK.

Enable TCP/IP and Named Pipes, then tick the option Enable Shared Memory Protocol and click OK.

Hope this helps.




回答2:


Thanks to Birel for pointing me in the right direction. The answer was that on the new 2014 server, the 'SQL Server Browser Service' was not running. I set it to automatic startup, and started it. That resolved the issue.



来源:https://stackoverflow.com/questions/52502714/intermittent-odbc-connection-failures

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!