Developed a Windows application that remotely accesses an SQL Server online. However, the client's ISP blocks port 1433. What are the other options to connect to SQL Server from the windows app?
SQL Server should have a network utility where you can configure the port to be used. Contact your client's ISP to see which ports are open (they may even be able to open up 1433 for you) then configure the server to use that port.
In my install, you select: "Start > All programs > Microsoft SQL Server > Server Network utility", select "Enabled Protocols" then "TCP/IP" and "Properties".
From there you can set the default port to a more accessible one.
You could change the port number that SQL Server runs under, to use a port that is actually open at the ISP.
Since 1433 is the default port for SQL Server, it is a common target for hackers. Some ISPs pick an arbitrary port number to obfuscate this. You may need to find what port number that is from them.
Another option is to use a WCF Web Service hosted in IIS and have your windows app call this service.
Related
I have a SQL Server running on Microsoft Azure. I want to connect it to My Project in Visual Studio 2015 Community. I have added my IP address in firewall on server. I have also made my port 1433 open for sql. But when I try to connect to database this error shows up. Error Message in SQL Server
It appears that this is a two step process and you either missed the VM configuration or the Azure configuration. Based on what you said I believe it is the Azure configuration that may have been missed. This blog post appears to highlight the necessary things that need to be done to connect.
https://blogs.msdn.microsoft.com/ggaurav/2014/01/08/connect-to-sql-database-on-azure-iaas-from-ssms/
Below is an excerpt:
The two settings which you have to make sure you are checking are :
Endpoint is configured for the port on which SQL server is listening ( generally 1433) on the VM machine.
Ports are opened on the VM machine. Even though as per the documentation Cloud adaptor takes care of opening the firewall ports,
it doesn’t work for the normal connections which you are trying to
make. Just type in ” wf.msc” and create a rule for both outgoing and
incoming for TCP port 1433.
As soon as you are done with these two, you would be able to connect
to the SQL server on the VM machine.
According to your description, I guess your SQL database is a Azure service, not install SQL on Azure VM.
If I understand it correctly, we should check SQL database firewall settings and confirm the name of your database.
The error code means, this error could occur because either the
firewall on the server has refused the connection or the server is not
configured to accept remote connections.
We can via Azure Portal to check the firewall settings:
Make sure the Allow access to Azure Services is ON,
And make sure your client IP address have added to the Client IP address list.
Also we should confirm the name of your database, make sure we are connect to the right SQL database.
I have also made my port 1433 open for sql. But when I try to connect to database this error shows up.
You also need to enable 1433 port in Network Security Group which related to your VM. Steps below are for your reference.
Find the Network Security Group name which related to your VM in Netowrk interfaces panel.
Open this NSG, click [Add] button in the Inbound security rules panel
Add a rule as following.
After that, we could access the database hosted in VM using following server name format.
Server name format.
[IP address/dns name],1433
For example,
13.81.50.123,1433
How to connect sql server from client systems to main host system through internet and IP address?, like a software in the company representatives that connected to main office's software through Internet?
You should Enable Network Access in SQL Server Configuration Manager.
See:
On the Start menu, choose All Programs, point to Microsoft SQL Server and then click SQL Server Configuration Manager.
Optionally, you can open Computer Manager by right-clicking My Computer and choosing Manage. In Computer Management, expand Services and Applications, expand SQL Server Configuration Manager.
List item
Expand SQL Server Network Configuration, and then click Protocols for InstanceName.
In the list of protocols, right-click the protocol you want to enable, and then click Enable.
The icon for the protocol will change to show that the protocol is enabled.
To disable the protocol, follow the same steps, but choose Disable in step 3.
Your sql server should be allowing remote connections. Then you need to get through firewall. This isn't the appropriate/recommended way of accessing data though.
I would recommend that you use services in between to fetch data. so your architecture should be something like this
Client machine--Web services(any type)--Database
Database--web services--client machine
Is the server hosted in your network ? if so then you will have to configure server to allow access to users
If it is not in your network then you will need to open firewall for client IP.
So Im running a Sql Server 2012 in a virtual machine on my computer and I want to be able to connect on it with the SqlConnection on Visual Studio, but I have no idea what to put on the servername parameter.
I dont know if I have to put the vm ipaddress or the machine address "WIN-NIJ53etc\SQLEXPRESS"
UPDATED:
FOR MIGRATING BETWEEN SQL CE AND SQL SERVER: Please take a look at this instruction here.
You should follow these steps:
1- Set the virtual machine to have a physical IP address.
For configuring network on Microsoft Virtual PC: http://support.microsoft.com/kb/833134
2- Be sure that you can see the VM with a static IP address. (ping is a good idea for checking that, but don't forget to turn off the firewall on the target machine, I mean the machine you wanna ping. There is no need for the server to see the client, so check that your client (in this case your VM) can ping the server IP address like "ping 192.168.10.1 -t")
3- Use Configuration Manager (All Programs\Microsoft SQL Server\Configuration Tools) and set SQL port and visibility over network.
Reference: http://msdn.microsoft.com/en-us/library/ms189083(v=sql.105).aspx
4- Restart the SQL server.
5- Be sure that "SQL Server Browser" service is started. (incase you wanna use the instance name to access the SQL server)
6- Config the firewall on the host machine (machine that has SQL engine) and add the port you specified in the Configuration Manager to TCP Inbound rules.
Take a look at here: http://www.tavislovell.com/post/How-to-configure-Windows-Firewall-to-allow-access-to-SQL-Server.aspx
BUT be advised that you should set the port specified in the Configuration Manager (default is 1433 but sometimes it's dynamic and you should set it again)
7- After you set the port and network visibility, you should change the "Server" value in the connection string to this format "IPAddress, PORT" like "192.168.10.50, 1433" (When you specify the port, there is no need to set the instance name like this "192.168.10.50\SQLEXPRESS")
Hope it helps
Ahh the joys of SQL Server Installation setup.
Make sure you have:
Network communication between the VM and the client computer (ping will work)
The SQL Server Service configured to start automatically or that it is started
The service configured to use TCP (if you don't want to use Named Pipes)
Either the SQL Server Browser enabled and started or that a static port is configured (1433 or similar)
The firewall rules configured to allow 1433 (or the port you have chosen) and 1434 (if you are using browser)
The connection string using the proper format Computer Name\Instance (to use browser) or Computer Name,port (if you are using a static port
There is a good tutorial on MSDN that may prove helpful. With specific regard to the Server Name/IP question, it doesn't matter so long as the client computer can resolve it. If you are testing, "IP,Port" is the most reliable (E.g. 10.10.10.100,1433) as it does not depend on NetBIOS, DNS nor the SQL Browser service.
How can I check whether SQL Server is installed in a system on a network?
I have to find it using IP address. Is this possible?
How to achieve it in c# code?
You could try to use WMI.
Here's how to detect if SQL Server is installed using WMI: FAQ: Detecting SQL Server 2005 using WMI (works for 2005, should be easy to adapt for other versions).
To connect to a remote computer using WMI, read this.
Of course WMI must be installed, accessible, etc.
In general SQL Server listens on port 1433:
http://support.microsoft.com/kb/287932
so if you find that this port is open there is a good chance (but not certain) that SQL Server is installed on that machine and is accessible.
You can check that this port is open by opening a socket to it: see the Socket class (doc: http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx) for details.
However, it's also possible to install SQL Server in many other modes where it is not accessible through this port. It's also possible to have this port open (and responsive) from other programs.
It's worth bearing in mind that best practice for securing a server accessible over the Internet would have the SQL Server on a non-standard port, no access to WMI, and (ideally) the server locked down to only open its port to the TCP/IP addresses of known white-listed clients. So in general: there is no way to do this scan that will always work. (Just as well, if you think about it...)
I am using VSTS 2008 + C# + ADO.Net + SQL Server 2008. My questions about what kinds of communication protocols SQL Server 2008 will be using, more details of my questions,
If the connection string looks like this, whether Named Pipe or TCP/IP is used? Will different communication protocol being used dependent on whether client and SQL Server on the same machine?
Data Source=labtest1;Initial Catalog=CustomerDB;Trusted_Connection=true;Asynchronous
In SQL Server Configuration Manager, there are items called "SQL Server Network Configuration" and "SQL Native Client 10.0 Configuration". I find both of them has configuration options (for communication protocols) of Named Pipe or TCP/IP, what are the differences between "SQL Server Network Configuration" and "SQL Native Client 10.0 Configuration"?
According to SQL Server 2008 Books Online, this is what happens:
Connecting Locally on the Server
When you connect to the Database Engine from a local client (the client application and SQL Server are on the same computer), the connection uses shared memory protocol by default. SQL Server Native Client accepts any of the following formats to connect locally using the shared memory protocol:
""
"\" for a named instance "(local)"
"(local)\" for a named instance
"Localhost"
"localhost\" for a named instance
A single period "."
".\" for a named instance
To connect locally using another protocol (for troubleshooting), do one of the following with the protocol enabled:
Connect to a client alias that specifies a protocol. For more information, see "Aliases" in SQL Server Configuration Manager help.
Prefix the computer name with the protocol (for example, "np:" or "tcp:").
Connect to the IP address which results in a TCP/IP connection.
Connect to the fully qualified domain name (FQDN) which results in a TCP/IP connection (for example, "..com"
Connecting over the Network
By default, the default protocol for SQL Server clients is TCP/IP. If the connection cannot be made using TCP/IP, the other enabled protocols are attempted. A shared memory connection cannot be made over a network. Use SQL Server Configuration Manager to enable or disable client protocols, and to change the order in which connection attempts are made.
In the Sql Server Configuration Manager, you can define an order for the client protocols - I would assume that's the order the client tries to connect to SQL Server with. Whichever protocol is the first being supported by the server will be used.
AS for the configuration utility:
SQL Server Network Configuration is all about configuration of network protocols on the server side of things
SQL Native Client Configuration is the client-side configuration
If you have a dev box with both on it, you'll see both. A regular PC connecting to a SQL Server typically doesn't have SQL Server itself installed on it locally, so the server-side settings are meaningless there, obviously.
Marc
The settings configured in SQL Server Native Client Configuration are used on the computer running the client program. When configured on the computer running SQL Server, they affect only the client programs running on the server.
Microsoft SQL Server clients on a machine communicate with SQL Server servers using the protocols provided in the SQL Server Native Client library file.
Remember that these settings are not used by the Microsoft .NET SqlClient. The protocol order for .NET SqlClient is first TCP, and then named pipes, which cannot be changed.