Sql – how to access remote sql server database from vb.net windows form application

remote-accesssqlsql servervb.netwindows-forms-designer

i want to develop an application with SQL Server 2008 and Vb.Net.
my SQL server will running in one system and i want this server to be accessed by Vb application which is running in other computer (not in the same network/LAN).

my question is that,

  • Is is possible to access SQL Server Database from remote computers(which are running in different network – different part of the world) ?

  • will it require that all the computers which are accessing this server should be in running in same "Domain" ?

please help me in this.

please provide a simple vb.net code( windows form application) which will connect to Remote SQL Server Database.

Hearty thanks in advance..

Best Answer

To access a SQL database across the internet (using a non-VPN connection), you would need to use a connection string such as the following:

Data Source=x.x.x.x,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
  • Data Source = Remote server. You can use either the IP or full DNS name. If you are using a non-standard port (something other than 1433), you can specify it after the comma.
  • Initial Catalog = Database name on the remote server.
  • User ID = SQL user name and password. This will use SQL authentication, not integrated windows security.
  • Password = Password for the respective User ID.

A few things (warnings) about the remote server:

  • It will need to expose SQL through the internet. Firewalls would need to be configured to allow the connection to the SQL port.
  • It will need to be set to allowed Mixed Mode authentication with SQL user accounts setup that you can use in your connection string.

Simple VB.NET Code is available lots of places. Here is a sample on Microsoft's site. You would use the SqlClient connection information.