The below query after running for a while is showing a "Timeout expired error". I even set the "cmd.CommandTimeout = 3600", but after running for 1 minute I get the "Timeout expired error"
Sub ConnectSqlServer()
        Dim conn As ADODB.Connection
        Dim rs As ADODB.Recordset
        Dim sConnString As String
        Dim cmd As New ADODB.Command
        ' Create the connection string.
        sConnString = "Provider=SQLOLEDB;Data Source=server1;" & _
                      "Initial Catalog=database1;" & _
                      "Integrated Security=SSPI;"
         cmd.ActiveConnection = conn
        ' Create the Connection and Recordset objects.
        Set conn = New ADODB.Connection
        Set rs = New ADODB.Recordset
        cmd.CommandTimeout = 3600
        ' Open the connection and execute.
        conn.Open sConnString
        Set rs = conn.Execute("select column1, column2 from table1;")
        ' Check we have data.
        If Not rs.EOF Then
            ' Transfer result.
            Sheets(1).Range("A8").CopyFromRecordset rs
        ' Close the recordset
            rs.Close
        Else
            MsgBox "Error: No records returned.", vbCritical
        End If
        End Sub
Please let me know what need to changed in code to make it run for long time and show the results.
 
    