title: Connecting to SQL Server over network using ADO from Excel VBA
body: <p>I need to connect to a SQL Server DB running on my laptop from another computer on a network. I am doing this both from a C# app as well as in a VBA macro. Both run perfectly on my laptop and the C# app runs perfectly over the network. However I cannot connect using VBA over the network. This is my connection string:</p>
  
  <p><code>ConnectionString = "Driver={SQL Server};Server=MY-LAPTOP; DAtabase=SAFEXlive; UID = MyUsername; PWD=MyPassword"</code></p>
  
  <p>Aside from the 'Driver={SQL Server}' this is the same as the connection string I am using in the C# app which works.</p>
  
  <p>I am then using the following code (With a reference to Microsoft ActiveX Data Objects 6.0 Library in VBE) to open the connection:</p>
  
  <pre><code>Dim oConnection As Connection
  Set oConnection = New Connection
  oConnection.ConnectionString = strConnectionString
  oConnection.Open
  </code></pre>
  
  <p>This works correctly if I run it on my laptop but if I run it on another computer on the network I get the error: "Run-time error '-2147217843 (80040e4d) [Microsoft][ODBC Server Driver][SQL Server]Login failed for user..." and the user it specifies it the windows log in for the computer.</p>
  
  <p>Are there some security settings I need to set in code or in excel? Or am I constructing the connection string incorrectly? What am I doing wrong?</p>