title: Query Timeout Expired (Run time error - '2147217871'), when I am trying to execute a SQL view in VBA?
body: <p>The below VBA is the one I am working on and I am getting a </p>
  
  <blockquote>
    <p>Query Timeout Expired error (Run time error - '2147217871')</p>
  </blockquote>
  
  <p>when I tried to execute the below code:</p>
  
  <pre><code>Sub ConnectSqlServer2()
  
      Dim conn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim sConnString As String
  
      ' Create the connection string.
      sConnString = "Provider=SQLOLEDB;Data Source=adhoc23;" &amp; _
                    "Initial Catalog=database1;" &amp; _
                    "Integrated Security=SSPI;"
  
  
      ' Create the Connection and Recordset objects.
      Set conn = New ADODB.Connection
      Set rs = New ADODB.Recordset
  
      ' Open the connection and execute.
      conn.Open sConnString
      Set rs = conn.Execute("SELECT * FROM SQLViewName;")
  
      ' Check we have data.
      If Not rs.EOF Then
          ' Transfer result.
          Sheets(CC).Range("E5:G34").CopyFromRecordset rs
      ' Close the recordset
          rs.Close
      Else
          MsgBox "Error: No records returned.", vbCritical
      End If
  
      End Sub
  </code></pre>
  
  <p>Please let me know how I can resolve the time out expired error.</p>