Home > DeveloperSection > Forums > Error while connecting to remote SQL Server database
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    August-14-2014 5:12 AM

 C# C# 
Ratings:


 1 Reply(s)
 718  View(s)
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.



Pravesh Singh

Total Post:411

Points:2881
Posted on    August-14-2014 6:54 AM

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));


Don't want to miss updates? Please click the below button!

Follow MindStick