How to connect sql server through internet? - c#

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.

Related

Why my visual studio 2015 SQL Server doesn't connect with Azure SQL Database?

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

Need help in SQL Server Remote Access

how to connect two laptops to share a database using windows form application? i mean i've installed mssql server 2008 in my laptop, i need to make windows form application so my friend can modify the database from his laptop, it's not in LAN , we have to use Internet as medium to connect, it'd be helpful if anyone can show me some directions like how connection strings should be. thanks :)
You should consider looking into this. If you search for Error 40 or Error 26 SQL Server. You will get lot of links for connecting SQL Server remotely both on LAN and WAN.
Take a look at this link as well. Screenshots are added here
There are multiple steps involved
Enable default login (sa) - not a good practice
Enable remote connection on sql server
Enable SqlBrowser service - either through Sql Server configuration manager or type services.msc on Run(Ctrl + R)
Add SqlBrowser.exe to firewall exception
Open TCP port 1433 and add it to firewall
Enable TCP, NamedPipe in Sql Server Configuration manager.
Check your public IP using any site like Seemyip.com
Give this IP to your friend along with sql server instance name
On remote machine - enter IP\ServerName with credentials for sa.
OP you just need a dynamic DNS Record (for free at dyndns.org) and then you can create a port forwarding on your Router/Firewall to your SQL server.
That way your SQL Server will be accessible over the internet. Just update your connection string with the dynamic DNS entry that you registered.
This link would be helpful to set the configuration.The link tells how to manipulate connection string according to scenarios.
Here is your:
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;

MysqlBackup from C# remote server

I'm trying to do database backup using MysqlBackup library ( http://mysqlbackupnet.codeplex.com/ ).
When I'm working with my local Mysql Server everything is ok. I tried to connect to my website database, I receive exception:
Access denied for user <...> using password "YES"...
I know that I'm using correct data, maybe I need special settings on server to allow remote connections ?
When I'm connecting from PHP, the db server that I use is "localhost", in C# application I'm using as server my site address.
It's definitely remote connection not enabled, problem.
Just Google How to Enable Remote MySQL Connection in cPanel
Here is the answer below URL:
CPanel Guide for this
You probably can't enable full remote connection access without root access to your server most likely if your server doesn't have ssh running then the best you can do is just add your ip address so mysql will allow you to connect from your C# program's IP address. Which the guide above tells you how to do.
Enable Remote MySQL Connections in cPanel
Remote MySQL connections are disabled by default in cPanel servers because they are considered a potential security threat. Using the tools in the Web Host Manager (WHM) and the domain-level cPanel interface (usually http://domainname.com/cpanel) remote hosts can be added which the server allows to connect to the MySQL service.
Please note that Liquid Web Shared customers are not permitted to use remote MySQL connections in order to ensure the security of the other customers on the same server. This guide pertains to Dedicated and VPS customers running Linux servers with cPanel.
Before using either of the following techniques, you will need to to open up port 3306 in your server’s firewall.
Enabling Remote MySQL in the WHM Interface
Log in to the server’s WHM interface and find the section in the left-side navigation bar labeled SQL Services. Click on the link marked Additional MySQL Access Hosts:
On the following page, enter one or more hosts or IP addresses in the text box (1) and click the Save button (2). If you wish to activate these settings on all user accounts see (3).
Now that the remote connection has been activated in the WHM each domain account that wants to use the remote connection will need to activate it in their own cPanel interface.
Enabling Remote MySQL in the Domain cPanel Interface
Using the X3 cPanel theme:
Log in to the domain’s cPanel interface and find the section on the main page labeled Databases.
In the Databases section find the link/button labeled Remote MySQL and click on it.
The following page will appear in your browser. Add a hostname or IP address that you want to grant remote MySQL access to (1) and then click the Save button (2).
If a host or IP address needs to be removed from this list you can click the red X next to the entry in the list.

SQL Server c# connection

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.

SQL Server's port is blocked

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.

Categories

Resources