SQL Mirroring 2008 R2 - sql

I have a mirror and witness setup with automatic failover setup. The server side of the mirroring works fine, when we take the network cable out the databases failover to the failover server.
The problem I have is that the connection string that I am using:
Driver={SQL Server};Server=WCFTEPATSQL01;Failover_Partner=WCFTEPATSQL02;Initial Database=DBForms;Trusted_Connection=SSPI;Network=dbmssocn;Pooling=false
is not sending the connection to the failover partner when the primary server is down. I can change the server address to the failover address and this will work but this is not what I should be doing.
The setup is classic asp on IIS 7.5.
Any help would be great as I have tried almost everything out there.

I have solved my own issue, it looks like the SQL Server driver didn't recognise the Failover Partner, I changed the connection string to:
Driver={SQL Server Native Client 10.0};Failover_Partner=WCFTEPATSQL02;Server=WCFTEPATSQL01;Database=DBForms;Trusted_Connection=yes;Network=dbmssocn;Pooling=false
and all is good.

Related

.NET SQL Server Connection by name and IP differs in behavior

Not sure if this is a StackOverflow question, but we hit this really strange problem with our ASP.NET 4 web app.
So, there is a typical connection string to SQL Server with Data Source specified in web.config.
SQL Server is run on VM on the same host as Web VM runs. They are in one network. If we specify connection using VM name, like "sql-server-vm", the web app works properly without any issues. But if we specify IP address of SQL Server VM instead, we start running into transient issues, like long server answers or timeouts.
Trying tracert the IP from the Web server VM shows the proper IP, so it's definitely the same machine and it is avaliable by name and IP. We are using ASP.NET Web API 2, ADO.NET, SQL Server 2014 SP3 in this project.
Is it possible that connection using ADO.NET does not properly work with IP address, but works with SQL Server Instance name? I cannot imagine a reason for this, but this is clearly what happens.

SQL Server 2008 database mirroring

I have a little problem with the database connection. There are 2 database server:
DBSA, DBSB
DBSA (primary server)
DBSB (mirrored server)
I connect with the following Connection String :
Data Source=DBSA;Failover Partner=DBSB;Persist Security Info=True;Initial Catalog=database;User ID=user;Password=password
When I run my program on my PC it works, but when I try the program on the web server in the DMZ the failover doesn't work.
Does somebody knows the reason for this?
=> I forgot to tell in the question. There is also a witness server.
The app must be getting the failover server name from the SQL server (probably not even the FQDN name) instead of the connection string in the web.config.
Try running ipconfig /flushdns then failover the SQL database and after you get the first SQL exception error run ipconfig /displaydns to see which name it cannot resolve. My bet is it doesn't look anything like the DB alias you have set up in the connection string for failover partner...
I had to deal with the same thing - Microsoft's implementation is a little convoluted since they're trying to cover every possible scenario.
Run this on your principal db
SELECT DB_NAME(database_id) AS 'DatabaseName'
, mirroring_role_desc
, mirroring_safety_level_desc
, mirroring_state_desc
, mirroring_partner_instance
FROM
sys.database_mirroring WHERE mirroring_guid IS NOT NULL;
The value returned in mirroring_partner_instance is the server name that will be used by your connection for failover, not what you specify in the config.
I imagine your PC can see this server using this name, where as when running in the DMZ it cannot.

Issues connecting to sql server from outside domain

I am having issues connecting to sql server either through SSMS or my C# application.
One thing to note is that I am out of my work domain. But I have in the past worked from home before and didn't had any issues. Maybe once but I restarted and it worked. But it's not working today.
Microsoft SQL Server ERROR 2
Establish whether the correct port is open and listening (TCP port 1433 by default) you may need to speak to your network administrator for this.
The SQL Server Browser Service may also need to be running.
If not the above then perhaps an authentication issue...
Finally managed to fix it. Logged on to sql server configuration manager and under sql server services I noticed that all the services were stopped. Just started the SQL Server (MSSQLSERVER) manually and everything is back to normal.
Thank you everyone for your time and input. Much appreciated.

Connecting to SQL Server Express 2008 from a CE device

I've developing a .NET Compact Framework app that needs to connect to SQL Server 2008 Express on another machine (Windows 7 x64).
I'm tearing my hair out here - I can ping both ways from the device to the machine etc (although I lose some packets - presumably because at the moment the wireless router is miles away and we don't get much signal down here), but when I try and debug the application on the CE machine it always fails to find SQL Server.
I've tried a variety of different connection strings with no joy.
Here's the connection string I've got at the moment:
Data Source=10.0.0.12;Initial Catalog=EMS_Main;User ID=sa;Password=password;
Firewall is off.
Thanks
Do you have your SQL Express instance set up to accept remote connections? Do you have WIndows Firewall turned off, or allowing the port access for SQL Server?

Cannot connect to Azure SQL database, even with whitelisted IP

I am currently unable to connect to my Azure SQL database from a separate remote standalone dedicated box in a private datacenter.
I have an Azure SQL database where I manage the list of IP addresses that can connect to this database. This has worked perfectly until now. I have recently set-up a new dedicated box in a private datacenter that needs to query the Azure SQL database at regular 5 second intervals, give or take.
The problem is, this dedicated box cannot establish a connection to the Azure SQL database, despite being able to connect to other remote FTP servers, MySQL servers, etc. The Azure SQL database does have the IP address of the dedicated box on the allowed connection list. Furthermore, I temporarily opened up a massive range of allowed IP addresses (0.0.0.0 -> 255.255.255.255) on the Azure SQL database to see whether this inability to connect may have resulted from IP blocking.
Does anyone have any suggestions or thoughts on what might be causing this and how I could begin debugging the situation better?
To clarify: I can connect to the Azure SQL database from laptops with individual IP addresses in my office and elsewhere, so long as they have been added to the database whitelist; I can make outward connections to remote FTP and MySQL servers from the dedicated box; I have tried to open-up a massive range of allowed IP addresses on Azure SQL with no luck.
Edit
C:\Users\graphite.rack.ID17157>osql -S v7o06blktw.database.windows.net -U XXXXXXX#v7o06blktw -P XXXXXXX
[SQL Server Native Client 11.0] Named Pipes Provider: Could not open a
connection to SQL Server [53].
[SQL Server Native Client 11.0] Login timeout expired
[SQL Server Native Client 11.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.
To summarize.
Windows Azure SQL Database (formerly known as SQL Azure) works exclusively and only on TCP port 1433. It only support SQL Server Authentication, TCP connection and TDS protocol as of today.
In order to successfully establish connection to SQL Azure one must fulfil the following requirements:
Create SQL Azure server & Database
Setup SQL Azure Server's firewall rules to accept connections from the IP address of application that will connect to that server
Make sure the box (be it Virtual, or home, or whatever) has no blocking outbound TCP port 1433
Explicitly force encryption in connection string
Explicitly chose to not trust server certificate in connection string
Please note that many (if not all) ISPs (Internet Service Providers) and Hosters, as well as IT staff within companies DO block outgoing TCP Port 1433 due to the SQL Slammer worm. This outgoing port blocking appears to be one of the most faced issues of newcommers to SQL Azure.
UPDATE Nov. 2015
As of August 2015, there is preview feature that enables you to use Azure AD to authenticate to Azure SQL Database. You can read more on this new preview feature here: https://azure.microsoft.com/en-us/documentation/articles/sql-database-aad-authentication/
If you're using corporate network for internet access and facing this problem,
a simple way around this is to use your phone's mobile hotspot for internet access instead.
Be sure to disable your ethernet connection too, which may also be connected to the internet.
Spent hours on this issue. The fix for me was finally found to be my setting on the Xfinity firewall. I had it set to high. Once I changed the setting to low security, I could connect to the Azure sql database with no issues.