TableAdapter.Fill raises "A Network-Related or Instance-Specific Error"
<p>I'm currently developing a program using Visual Studio 2010 and SQL Server 2008 R2.</p>

<p>I'm currently facing a problem while connecting to a SQL Server. For starters, I have a station with IP <strong>192.168.15.101</strong> establishing a connection to a SQL Server with IP <strong>192.168.0.11</strong>. </p>

<p>This station can successfully ping the server, and I can also connect to SQL Server located in the server from SQL Server Management Studio. The code below runs smoothly as well : </p>

<pre><code>    .extQuery = *SQL Query Here*
    Try
        If InternalSupport.RefreshConnection(False, GlobalVar.connectionString, GlobalVar.Server, False) Then
            .command = New SqlCommand(.extQuery, .connect)
            .reader = .command.ExecuteReader
            While .reader.Read
                *Some Code Here*
            End While
            .reader.Close()
            .command.Dispose()
            .connect.Close()
     Catch ex As Exception
        *Error Handling Here*
     End Try
</code></pre>

<p>However, the problem lies when I tried to refill my Table Adapter for VS Built in Data Source. Whenever I call the code below :</p>

<pre><code>    Me.TEMPORARY_DUETableAdapter.Fill(Me.DsAscendPending.TEMPORARY_DUE)
</code></pre>

<p>It raises this error : </p>

<p><strong>A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</strong></p>

<p>What I have tried are :</p>

<ol>
<li>Allow Remote Connection on SQL Server on Server side.</li>
<li>Set Connection String Dynamically from code.</li>
<li>Disabling windows firewall and antivirus.</li>
<li>Make sure all the ports and IP in SQL Server are open</li>
<li>Connect SQL Server from SQL Server Management Studio located on remote location, and it connects perfectly.</li>
</ol>

<p>Any help on this error is greatly appreciated. Thanks!</p>

<hr>

<h2>SOLUTION</h2>

<p>I've found the solution. The problem lies in my Connection String. I was using server computer name as Data Source instead of IP.</p>

<p>Below is my previous Connection String : </p>

<pre><code>connectionString="Data Source=MAIL-SERVER;Initial Catalog=MG_CreativeLab;Persist Security Info=False;User ID=sa;Password=#adminmedan123#"
</code></pre>

<p>It will allow connection from the <strong>same IP Segment</strong>, while rejecting connection from other segments</p>

<p>Here's the correct connection string : </p>

<pre><code>connectionString="Data Source=192.168.0.11;Initial Catalog=MG_CreativeLab;Persist Security Info=False;User ID=sa;Password=#adminmedan123#"
</code></pre>

<p>Thank you for the response!</p>