Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My vb.net application needs user to connect SQL database remotely. Remote connection works fine when both computers are in same network (wifi) but can not connect to server when internet network is changed for user computer. SQL configuration, TCP/IP settings, firewall are done. Please note connection is established with IP address when same wifi network used. What could be missing ?

What I have tried:

SQL configuration, TCP/IP settings, firewall are done.
Posted
Updated 4-Aug-19 1:25am
Comments
Richard MacCutchan 4-Aug-19 6:40am    
Check the connectivity, IP addresses, ports etc.

At a guess, you aren't changing the IP address to a "public" IP: if it starts 192.168.nnn.nnn then it's a local address which never leaves your LAN - internet IPs are never in that range.
So if the DB is hosted on your network, then "192.168.0.10" will address your server from your dev PC, but could be a printer, or a tablet on the customers.
 
Share this answer
 
Comments
Member 11793729 4-Aug-19 7:09am    
Thanks for reply, but I got my Public IP from third party web and tried. I didn't work. I am using SQL express & also developer editions. Are these have anything to do with ?
OriginalGriff 4-Aug-19 7:18am    
Try not to use as few words as possible - we only get exactly what you type to work from, so we get no context beyond that.
So we don't know what "I got my Public IP from third party web and tried" means, and what happened when "I didn't work" is a mystery to us.
Try to explain exactly where the DB server is, where the computer you successfully tested form is, and where the client is. Tell us the connection string you used for each computer - censor out the passwords, please - and what happened when you did that. Any error messages are a definite bonus!
Member 11793729 4-Aug-19 7:39am    
Sorry or typo and sincere thanks for your help. I got public IP of my SQL machine, from some web sites (all of them show same). I tested with this public IP but fired error saying, server not found. I am using below connection string :

Dim SQLConStr as string = "Data Source=" & VarServer & "," & VarIPSQLPort & ";Initial Catalog= " & VarSQLDB & ";Persist Security Info=True;User ID=" & IPSQLUID & ";Password=" & IPSQLPSS & ";integrated security=false;"

Variable VarServer consist = IP address + Machine Name + SQL Instance Name
OriginalGriff 4-Aug-19 7:57am    
Ah. You are self hosting. OK ...
First, check your internet connection: is it a static or dynamic IP? If you don't know, it's probably dynamic - you generally have to pay your ISP extra for static IP. Dynamic is bad: if your connection fails, there is no guarantee at all that you will get the same IP address when the router reestablishes the connection. So a power cut, hardware failure, whatever - and your clients are permanently disconnected.
Second, are you really sure you want to do this? It's dangerous - you are opening your DB server up to everyone on the internet who wants to "have a go". Make absolutely sure that Remote Access is what you need, and change the login info for the admin account(s) before you do anything: if you leave the default "sa" account alive then you deserve everything you are going to get ...

Now check if "Remote Access" is enabled on your SQL server: if you are using SQL Express then it probably isn't: https://blogs.msdn.microsoft.com/sqlexpress/2005/05/05/how-to-configure-express-to-accept-remote-connections/
Member 11793729 4-Aug-19 8:29am    
Your comment : "Sure you want to do this? It's dangerous" - Connection string details are not shared with any user and saved in encrypted way. App file assembles when needed. Do you think its not safe ? What is safe alternative to connect remotely. There are limited but scattered users and will be connecting from different locations.
Few things to check using Configuration Manager
- If possible, do not use dynamic ports: Configure a Server to Listen on a Specific TCP Port - SQL Server | Microsoft Docs[^]
- Ensure that port 1433 is allowed by all firewalls between the end-points
- If you use named instance, dynamic ports may be needed, depending on other instances, see Configure the Windows Firewall to Allow SQL Server Access - SQL Server | Microsoft Docs[^] , especially Dynamic Ports section[^]
 
Share this answer
 
Comments
Member 11793729 4-Aug-19 7:52am    
All working fine with same network using IP address, port 1433, name instance etc. Same thing don't work once internet network is changed for client machine.
Wendelius 4-Aug-19 8:01am    
It's not only the firewall on your side but also on the client side and possible firewalls in-between. All of them need to allow network traffic to selected IP addresses and ports.

Just to make sure that the IP address is correct, have you tried pinging the database from the client side? Does ping work?
Member 11793729 4-Aug-19 8:20am    
Thanks for help. You are right, I tried ping and its not working but working for same network ( i think thats using LAN IP address). Possibly problem with public IP address.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900