VB.NET to connect to an Online SQL Server 2008 - vb.net

I can connect with VB.net to SQL Server via using connection Strings
Dim Sqlconn As New SqlConnection("Server=:serverip:;Database=:DB:; uid= :uid:; pwd=:pwd:;")
I use this to connect locally (in the office).
my question: is there a way for me to connect in an ONLINE manner? ie I will connect my application from two far locations, from the United States to the SQL Server which is in the Philippines.
I'm guessing it has something to do with the "server = ;" part of the connection string.
Any help is dearly appreciated, thank you in advance

Basically the IP could be of any location. Just replace the IP of your connection string and it will work for you. NO difference in online and offline server.
The server IP will be your Data source which is the combination of the IP and the instance name. If it is the default instance then only ip will do for you but if it is the user defined instance then you have to mention the ip\instance name too.

An online connection string is no different from a local one. Just replace the serverip part with the public facing IP address of your "online" server.
If your machine can be accessed via the internet it will have an IP address on the local network and an IP address that it uses on the Public (Internet) side.
You will need to request a static IP address from your ISP, or else this public IP address may change over time and your connection will break. There is usually a charge for this.

We ended up using a VPN Software. HAMACHI. It provided our server with a unique Public IP which I then used as input for the "Server=;" requirement of the connection string.
Might help some people who are having the same problems, but I will still welcome new answers.

Related

Using external IP (Networking) (Apache)

I'm setting up a tool that relays and verifies information. One of it's protocols though is to verify if the server trying to challenge a key is whitelisted.
Problem now is server 1 and 2 is in the same network. When I make server 1 connect to (somedomain.com), which is routed back to server 2. Server 2 recognizes remote address as the (local ip) not the public IP. (Even if I explicitly ask server 1 to connect using IP instead of Domain name.)
This creates problems as (Long story) but server 2 needs to recognize server 1's public IP and not Internal IP.
Would appreciate any help or tips I can get from this.
Cheers,
Jet
You can route traffic via external server using SSH or proxy.

Google Cloud SQL Authorized Network can't connect

I'm trying to connect to my Google Cloud SQL instance from my desktop but am getting the following error:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
According to the docs this means that the client's IP isn't authorised to access the instance. I have done the standard "what's my ip" google search and added the IP to the "Authorised Networks" list of the instance (as well as a bunch of variations and /x ranges - none have worked, yes I restarted the instance). I have set a root password and even tried connecting with the necessary SSL certs - yields the same error.
I can connect to other (non-google) sql databases, I can ping the database, and I'm not behind any significant firewalls.
How i'm typically trying to connect (also tried SSL):
mysql --host=the.instance.ip.add --user=root --password
Nothing I try seems to work.
I feel like I must be missing something obvious - any suggestions welcome (this is a nightmare).
Could you check again if you have authorized the correct IP address.
If using your desktop from home, you may be having a private IP address for the desktop. What you really need to authorize is the public IP address.
The "what's my ip" search on Google doesn't currently work properly when the ISP is proxying the web traffic transparently. Better information on the IP seems to be provided by Proxy Test from http://www.lagado.com/proxy-test.
Make sure that the IP you are using is the public IP, keep in mind that this can change from time to time depending on your Internet provider. The easiest way to authorize any network is to add 0.0.0.0/0 to the witelist
I check my ip addres in this page https://www.whatismyip.com/es/

Connecting to SQL Server

I have successfully executed my SQL script on Microsoft SQL Server 2008 R2. Since I am a novice at this software, I would like to know how do I connect this database with my android application? Any help would be appreciated. Previously, I was making use of MySQL on XAMPP and hosting the database using my local machine. I made use of services being provided by http://www.noip.com to host the database since I do not have a static ip address.
Thanks in advance.
Your client will have a connection string. It will usually look like one of the examples here:
http://www.connectionstrings.com/sql-server-2008
You'll probably use the "IP Address" example. From the link above:
Connect via an IP address
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;
You're trying to use http://www.noip.com to deal with the fact you don't have a static IP address on your home network.
I would table this part of the problem for the time being. Go to your router and find your "external IP address"
You'll have to setup some port forwarding on your local network. I'm assuming (since you didn't give any detail) that you have a cable-modem at home and a wireless router. Your router will have to be configured to handle port forwarding so that when a request comes into 55.555.555.55 (your "external ip").......it will be forwarded to your internal Sql server (like 192.168.1.33). And you'll have to know the port. "1433" is the normal port, but can be changed.
So again, any requests coming into your cable-modem and router to "55.555.555.55:1433" will have to be forwarded to your internal IP and port "192.168.1.33:1433".
Your local sql server may have firewall rules that you need to alter to open up "192.168.1.33:1433" to your router.
If you get all that working, you'll have to wire up http://www.noip.com, which I am assuming gives you a static IP address and will link up your "55.555.555.55" to something permanent, with the caveat that when your "55.555.555.55" changes to "55.555.333.44", it'll handle the mapping for you.
So if noip gives you an IP of "777.77.77.7777" (which maps to "55.555.555.55" or "55.555.333.44" or whatever IP your internet provider gives you), you'll change your connection string to be "777.77.77.7777"
That's alot of drama.
But if you want to tackle it, there are some helper hints.
At the end of the day, your client app will have a connection string with an IP address and a Port Number in it, and that client will have to be able to reach your sql server.....through all the voodoo channels.
Good luck.
I would get this working first:
Data Source=55.555.555.55,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;
And then work in the noip.com part later. So eventually your connection string will become:
Data Source=777.77.77.7777,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;

SQL Azure connection string speed (IP or domain)

Until now we always use an IP address in our connection string to the SQL. This way we think it will be faster because the user doesn't need to find the IP of the domain.
Now we are trying Microsoft Azure and we see that they use a domain name in the connection string.
Will be slower? sometimes we know it takes 100-400 milliseconds to resolve a domain name to an IP address, do we spend this time every reload of the page?
You need to access SQL Azure by the given server name, as you're connecting to a massive-scale system, not a single computer. Regarding delay on page load: I don't know how you architected your solution, but reloading a web page does not equate to re-establishing a database connection from web app to database.
The DNS resolution will be cached - it doesn't have to do a new look up each time. You can prove this by using resolving a DNS entry programatically via System.Net.Dns.GetHostAddresses() on a test page.
Edit: It will be cached by the calling server(s).

connect to SQL hosted on a local machine from my laptop (using an IP)

I set up an SQL server on my Windows 7 PC.
I have a laptop, from which I want to connect to the SQL server (using visual studio 2010).
I need to fill in a "server name" when creating a database connection.
I tried "My.IP.Address/SQLEXPRESS,custom-port", but that doesn't work. All examples talk about using server names which are formatted like so "TOM-PC/SQLEXPRESS", but I have an important requirement:
I want to be able to connect from anywhere (not only when in the same local network), therefore I'm trying to use the IP address (the port isn't simply 1433 since my ISP blocks it).
The custom port is open, and reachable in tests.
I've been Googling this all day long, but can't find a solution. Please help!
Thank you,
Tom
To access from a remote location, you need to setup port forwarding on your router. If you have a static external facing IP address, then you can use that for your server address (123.123.123.123\SQLEXPRESS), otherwise you will need to setup a dynamic DNS service like DynDNS.com that will give your router a hostname.
DynDNS Free allows you to create a
hostname that points to your home or
office IP address, providing an
easy-to-remember URL for quick access.
We also provide an update mechanism
which makes the hostname work with
your dynamic IP address. We continue
to offer this service free to the
Internet community as we have done so
for nearly 10 years.
should it not be My.IP.Address:custom-port/SQLEXPRESS ?
If you are saying that you have a PC at location A that has SQL and you want to be able to access it from anywhere, well, then you're going to need a static IP from your ISP, a firewall with the proper NAT rules. And even then, it'll be a different IP when you're local (within the same network) than it is when you are at the local coffee shop.
My suggestion would be to use the local server reference and install SQL on your laptop. If you publish your work to your PC at home, then it'll use the local SQL server there too. This is what I do. I use RedGate tools to sync up my DBs.
If you have SQL and VS on the same machine (your laptop) and are trying to connect to the SQL server from VS (e.g. in debugger), then try the following: (I'm working like this all the time)
You can use (local) or . as the server in a SQL connection to refer to the local machine.
In your case:
(local)\SQLEXPRESS
or
.\SQLEXPRESS
Is it possible you overlooked turning on TCP/IP fro SQLExpress in the configuration manager?
Have you tried using a wild card? For example let others access you through '%', since you want your computer to be accessed anywhere, your MySQL host is actually your IP address.