ADO - MS SQL Server, empecher un time out sans changer les parametres ?
Bonjour a vous et merci de votre temps et de votre aide.
J'ai une application Access qui utilise in BD MS SQL Server pour ses donnees et une partie de ses traitements.
Mon probleme est que j'ai un time out d'une minute sur ma connexion, donc si je depasse ce temps de traitement du cote de SQL, j'ai une erreur dans Access.
Je ne peux pas (c'est interdit par ma compagnie) changer la duree du time out. C'est 1 mn pas une seconde de plus.
Pour lancer mes traitements j'utilise :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Public Sub ExecuteExec(prmStoredProcName As String, ParamArray prmStoredProcParam() As Variant)
'Call a store procedure executing something
Dim storedProcConnection As New ADODB.Connection
Call storedProcConnection.Open("MonDSN")
Dim execCmd As String
Dim execParam As String
Dim p As Variant: For Each p In prmStoredProcParam
If execParam <> "" Then
execParam = execParam & ", "
End If
execParam = execParam & p
Next p
Dim db As DAO.Database: Set db = CurrentDb
execCmd = db.QueryDefs(prmStoredProcName).SQL & " " & execParam
db.Close: Set db = Nothing
Dim cmd As New ADODB.Command
With cmd
.ActiveConnection = storedProcConnection
.CommandText = execCmd
.CommandType = adCmdText
.Execute
End With
Set cmd = Nothing
Call storedProcConnection.Close: Set storedProcConnection = Nothing
End Sub |
Et pour les requetes de selection :
Code:
1 2 3 4 5 6 7 8
| Public Sub OpenSelectConnection()
If m_SelectConnection Is Nothing Then
Set m_SelectConnection = New ADODB.Connection
Call m_SelectConnection.Open("MonDSN")
End If
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Private Function ExecuteSelect(prmStoredProcName As String, ParamArray prmStoredProcParam() As Variant) As ADODB.Recordset
'Call a stroed procedure returning a recordset
Call OpenSelectConnection
Dim execCmd As String
Dim execParam As String
Dim p As Variant: For Each p In prmStoredProcParam
If execParam <> "" Then
execParam = execParam & ", "
End If
execParam = execParam & p
Next p
Dim db As DAO.Database: Set db = CurrentDb
execCmd = db.QueryDefs(prmStoredProcName).SQL & " " & execParam
db.Close: Set db = Nothing
Dim result As New ADODB.Recordset
With result
.ActiveConnection = m_SelectConnection
.Source = execCmd
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.Open
End With
Set ExecuteSelect = result: Set result = Nothing
End Function |
Code:
1 2 3 4 5 6 7 8
| Public Sub CloseSelectConnection()
If Not m_SelectConnection Is Nothing Then
Call m_SelectConnection.Close
Set m_SelectConnection = Nothing
End If
End Sub |
Je peux changer ce code au besoin.
Ma BD a des tables liees dans SQL server.
Ma question est : connaissez vous un moyen pour empecher le time out sans toucher au parametrage de la connexion.
A+