Erreur d'execution '2147217871

bonjour j'ai une erreur d’exécution '2147217871' lorsque j’exécute une requête sql sur base sql server

jai lu quil fallait que j'utilise CoomandTmeout , mais je ne sais pas ou et comment la mettre

voici mon code

Public Rscon
Public sname

Sub CONNBDD()

    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sConnString As String
 Dim fld As ADODB.Field
  Dim Target As Range

    ' Create the connection string.
    'sConnString = "Provider=SQLOLEDB; Data Source=.\SQLEXPRESS;Initial Catalog=ScadaNetDb;User ID=EXTERNE;Password=EXTERNEPCWIN2; Trusted_Connection=no"
    sConnString = "Provider=SQLOLEDB;Server=DESKTOP-KBC80U4\SQLEXPRESS;Database=ScadaNetDb1;Trusted_Connection=yes;"
    ' 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(" " & Rscon & " ")
'**********************
 '***************
Sheets(sname).Cells.ClearContents

 '************
 With Sheets(sname)
.Rows("2:65536").EntireRow.Delete
End With
'*********************
    Set Target = Sheets(sname).Range("a1")
 For Each fld In rs.Fields
    Target.Value = fld.Name
    Set Target = Target(1, 2)
  Next
    ' Check we have data.
    If Not rs.EOF Then
        ' Transfer result.
        Sheets(sname).Range("A2").CopyFromRecordset rs
    ' Close the recordset
        rs.Close
   ' Else
        'MsgBox "Error: No records returned.", vbCritical
    End If

    ' Clean up
    If CBool(conn.State And adStateOpen) Then conn.Close
    Set conn = Nothing
    Set rs = Nothing
End Sub

merci pour votre aide

Rechercher des sujets similaires à "erreur execution 2147217871"