I want to access a remote hosted database from my local running asp.net web application. Is it possible to access it?
Well, it depends on the database hosting, and where it is being hosted.
Most web hosting plans – especailly the lower cost ones do NOT expose their database to external connecitons.
So, while the web site and web code can connect to the database (behind the web server), that same database is RARE exposed to the wild internet.
In fact, it was about 16 years ago, I was running a computer at home. I decided to open up the ports on my router, and expose the running instance of sql server. Well, in LESS then 20 minutes, automated bots were ALREADY attempting to log on to my database server. the logs looked like
logon fail: user sa, password = "password" logon fail: user sa, passwrod = "12345678"
etc. etc. etec.
So, while you can say hit amazon’s site to buy somthing, you certainly can not just direct connect to the database from the VERY nasty and dangrous and wild internet.
So, in most cases, the web server (and database) are behind a secuired fire wall, and the ONLY traffic allowed is to hit the web site. but the database server? Not a chance, as it is too dangrous.
However, with the recent rise of SQL Azure etc, then we do see a trend to allowing direct connections to say a database, and you 100% by-pass the web site. However, even in these cases, often the conneciton is now restriced by say IP address. So, you still often have to say VPN into the workplace network, and then your connection to the database looks like and comes from ONE IP address that is allowed, and not the WHOLE wild internet.
So, how you connect, and such connection technologes are FAR FAR beyond that of a simple answer on SO.
However, the answer is yes, you can connect to a hosted database, but what, where, what kind of hosting of that database in question is somthing you not provided details about. As noted, most low cost web hosting plans include a database for the web site, but in most cases such lower cost plans do NOT allow external connections to the database that by-pass the web server. So, web server and your web site code can connect to the database – but certainly not outside connections are allowed to directly connect to the database. However, this ability if allowed will vary by hosting plan, and vary by what type of hosting you are using. (or in fact no web hosting, but maybe just database hosting plan). In most cases, some kind of SSL, or even a VPN connection is required before you can connect to the database, and as noted, a simple open database server that allows any old connection from the wild and crazy and VERY dangerous internet is simply not allowed.
Answered By – Albert D. Kallal
Answer Checked By – Katrina (BugsFixing Volunteer)