Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need help! MSSQL and PHP

Author  Topic 

oregato
Starting Member

5 Posts

Posted - 2010-05-11 : 09:29:34
Hi guys,

i've got a database that is currently sitting on our internal company server, what i would like to do is allow our website to access the database. I.e. User can type in an integer and we will bring back the username and password etc..

I've tried everything but can't find anything that will work.

I've tried to open the ports etc etc.

Can anyone point me in the direction of a tutorial or sample that I could use.

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-05-11 : 09:34:56
Is your database server even acessible from the webserver? If the database is an internal company server it will need a public ip address and firewall openings in order to be accessed. Do you have this in place?

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

oregato
Starting Member

5 Posts

Posted - 2010-05-11 : 09:47:27
Hi Lumbago,

thanks for the quick reply.

We're unsure if the databse is accessible from the webserver and is hence the reason why I'm seeking you guys' expertise advice.

The database is on an internal company server yes which does have a static ip address. I've tried to open the firewall ports for 1433 but I'm having no joy.

Any help would be great.

Thanks
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2010-05-11 : 10:11:26
Organizations I have worked for did not allow direct access to an internal DB server directly from a web site due to security concerns. If this is the case then the main options are:
1. Write a Web Service to access the data on the internal server and consume it from the web site.
2. Have a separate DB in the DMZ and push data to it at regular intervals. The web site then accesses the DB server in the DMZ.

As you mentioned usernames and passwords, I suspect a Web Service may be a better idea.
Go to Top of Page

oregato
Starting Member

5 Posts

Posted - 2010-05-11 : 10:26:35
Hi Ifor, thanks for the reply.

I understand the risks of direct access into the internal DB but it will only be for read access only.

If I were to write a web service, could you give me a few examples or sample websites/tutorials to go to?

Number two, I've thought of doing, we already have a database on the DMW however, pushing data would not be an option because we have a lot of data and I don't want to have to replicate it in two places.

Could you give me some ideas to the web service or where to start looking.

Thanks
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2010-05-11 : 10:55:10
I would be inclined to write the web service in .Net but SQL Server ENDPOINTs or Java, C++ etc would be alternatives.

Google is probably the best place to start.
Go to Top of Page

oregato
Starting Member

5 Posts

Posted - 2010-05-11 : 11:01:16
Thanks again Ifor,

we already have a php based website that connects to a mysql database.

From my limited knowledge of webservices, we can write it in C#/.net and it would be possible for us to access it from the php based website yes?
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2010-05-11 : 11:29:07
You can certainly write a web service using C# and ASP.net.

I do not know much about PHP but there seem to be books on PHP and Web Services, so I presume the answer is Yes.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-05-12 : 02:37:14
How much data is in this database of yours? Replicating only the data you need on your website is probably the most common way to do this and it is also by far the safest way. A web service is also pretty safe but personally I'd think this is more work to set up. I havent done any replication like this recently but a few years back I set up a solution where roughly 50GB of data were "batch-replicated" every night in roughly 2 hours (it was done using BCP, not the native replication methods). You'd have to have a pretty serious amount of data before replicating data is no longer an option...

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

oregato
Starting Member

5 Posts

Posted - 2010-05-12 : 03:34:04
Lumbago,

I think you have a point, the database is not that big at the moment, but I fear that if it grows it will be more difficult to manage.

Hence why the web service seems like a very good option.

I think I'll invest the rest of the week into trying to get a web service up and running, and if that does not work, I'll do an export from the database up to the web server database.

Is there any good web service tutorials that you guys could point me in the direction to?

Thanks again guys

Will
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-05-12 : 03:59:45
I haven't read the entire article but this seems like a fairly decent tutorial on how to expose data from you sql server database as a web service

-> http://www.devx.com/dbzone/Article/28525

You still have to have some sort of external access to the internal server though, so you still have to sort that out. The concept of connecting to port 1433 is exactly the same as connecting to port 80 or 443...if there is no public IP there is no access :)

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page
   

- Advertisement -