ERROR WHILE CONNECTING TO REMOTE SQL SERVER DATABASE

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
C# 
C#
 966  View(s)
Ratings:
Rate this:

My problem is quite simple: I'm writing a WinForms app in .net 4.0 C# in Visual Studio 2010 it works nicely on my computer.

It connects to a remote SQL Server database using System.Data.SqlClient's SqlConnection.

When the program loads the first form it runs the following code:

SqlConnection ACconnection = new SqlConnection(String.Format(

        "Server=xxx.xx.xxx.xxx\\TEST;Database=REP01;User Id={0};Password={1};", User, Password));

private bool TestConnection()

{

    try

    {

        ACconnection.Open();

        lbl_connectionStatus.Text = "Server: Connected";

        lbl_connectionStatus.ForeColor = Color.FromArgb(0, 150, 30);

        ACconnection.Close();

        return true;

    }

    catch (Exception ex)

    {

        Functions.GetError(ex);

        return false;

    }           

}

I get the error:

SQL Network Interfaces, error: 26

My problem is that even though it is working fine on my computer it won't work nearly anywhere else. All the computers I've tried it are running on Windows 7 or 8, including mine.

I've googled the error, but all the answers focus on the server side, and since it's working fine from my computer I know it's not a server side problem.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Error while connecting to remote SQL Server database

    Hi Ankita, 

    try this:

    SqlConnection ACconnection = new SqlConnection(String.Format(

        "Server=xxx.xx.xxx.xxx\\TEST,49232;Database=REP01;User Id={0};Password={1};", User, Password));

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!