Search code examples
vb.netconnection-stringsqlconnection

connect to LAN sql server vb.net


I'm using VB.net and trying to connect to a distant SQL Server Database in a LAN network, I tried several connection strings but none was successful.

The connection string I tried is this:

Data Source=\\sage2\MSSQLSERVER,1433;Database=MATERIEL.MDF;Integrated Security=False;Network Library=dbmssocn;User Instance=False;user='" + TxtUser.Text + "';password='" + TxtPassword.Text + "'"


Solution

  • Although this is an old question, I would like to add something which might help future visitors. The answer by @Dolveras is right but you should also look at some extra things before trying to connect.

    1. Allow port 1433 or whatever SQL Server is using in the firewall of the server machine for inbound and outbound requests.

    2. Uncheck IPV6 in the Local Area Connection Properties on the server and client.

    Thanks and Best of Coding