1

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.

  • What language or system is your web site written / designed in? Connecting to SQL Server depends on where/what you want to connect from .... – marc_s May 07 '13 at 15:02
  • I am sorry Mark. I have edited my question. Can you please re-read it? – user2337704 May 07 '13 at 15:11
  • What best I can think of is that I host the database I have created in MSSQL 2008 R2 on my local machine using noip.com, of course. I use the link on my android application. However, I am not sure how to do the former. – user2337704 May 07 '13 at 15:28
  • 1
    Your question is very unclear, are you asking [how to connect to SQL Server from Android](http://stackoverflow.com/questions/3492417/connect-to-sql-server-from-android)? And why have you tagged this "website" and "xampp"? – Pondlife May 07 '13 at 15:41
  • Pondlife, I am sorry for being unclear. All I want to know is how do I host the database, created using Microsoft SQL Server 2008 R2, on my local machine. P.S. I will remove the unnecessary tags. – user2337704 May 07 '13 at 16:16

1 Answers1

0
  1. 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;
  1. 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"

  2. 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".

  1. Your local sql server may have firewall rules that you need to alter to open up "192.168.1.33:1433" to your router.

  2. 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;
granadaCoder
  • 26,328
  • 10
  • 113
  • 146