title: ADO .Net - How to specify source IP address in SqlConnection on system with multiple IP addresses
body: <p>I have server with a network adapter configured with multiple IP addresses. Different ASMX and WCF web services are installed on the server and for some security reason, for every WEB service i received from my network admins dedicated source IP address for connecting to specified RDBMS via ADO .Net. With lot of experiments I concluded that any SqlConnection object is connecting only via the first IP address configured on the network adapter (first IP address operate as a default source IP address).
  Is there any way to specify source IP address for a SqlConnection object ?
  I have already seen proposed solution for the similar problem at <a href="https://stackoverflow.com/questions/13727523/specify-source-ip-for-ado-connection-from-delphi-to-mysql">Specify Source IP for ADO connection from Delphi to MySQL</a> but that kind of solution is not applicable in my case.</p>
  
  <p>I need something more similar to the way presented bellow that is used in case of ASMX web service clients, where I can specify source IP address via callback:</p>
  
  <pre><code>protected override System.Net.WebRequest GetWebRequest(Uri uri)
  {
      System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri);
      webRequest.ServicePoint.BindIPEndPointDelegate += new System.Net.BindIPEndPoint(BindIPEndPointCallback);
      return webRequest;
  }
  private IPEndPoint BindIPEndPointCallback(ServicePoint sp, IPEndPoint epRemote, int tries)
  {
      IPAddress ipLocal;
      EndPoint epLocal;
      IPAddress.TryParse(strIPAddr, out ipLocal);
      if (tries &lt;= 3)
      {
          epLocal = new IPEndPoint(ipLocal, 0);
      }
      else
      {
          throw new Exception(string.Format("BindIPEndPointCallback: error connecting via {0}", strIPAddr));
      }
      return (IPEndPoint)epLocal;
  }
  </code></pre>
  
  <p>Is there anything similar for a SqlConnection object ?</p>