Hello all...incoming newbie question.

I'm new to building desktop apps after a couple of years using ASP.NET online. I'm using MS Visual C# 2010 Express to play around and learn with.

In order to test something that would be of real use to our company I want to be able to connect to our MS SQL database and pull out info...but I dont want to just connect through the local network. I want to be able to connect to it from anywhere my application is deployed, even off-site.

Can someone give me beginners pointers on how to connect to our MS SQL database in this manner?


Recommended Answers

All 2 Replies

You should be able to do it by entering the IP address for your MS SQL server in the Data Source section of the connection string:

Data Source=[B]myServerAddress[/B];Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

It's been a couple years since I've done this, but I'm pretty sure that's all you need to do, on the application side of things anyways. As long as the server & firewall and all that other networking stuff is set up correctly, you should be able to do it like this.

The basic principles of database connection remain the same between ASP.Net and Windows forms based applications. The only difference is that you are connecting to the DB from your local machine instead of from the webserver.

That being said, if the SQL Server is being hosted via a DNS you can connect using the URL to the server or the IP of the server just like you might connect to a remote SQL server from a web-app built on a separate server.

As bondo said the rest depends on server settings and such to ensure that your connection protocols match on both client and server side.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.