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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| Public Shared Sub EnregPerformance()
Dim strErrMsg As String
Dim DBEngine As Object
Dim ErrX As Object
Dim MaCle1 As String
Dim MaCle2 As Date
Dim MaCle3 As String
On Error GoTo ErrADO
'***
'*** ACCESS
'***
'*** Nom, DatePerf, Lieu, Dist, GainPerf, PartPerf, CordPerf, CordagePerf, FerPerf, Poid, DiscPerf, TypePerf, AlloPerf, Place, Cote, RedKDist
Gestion.RPerformances = New ADODB.Recordset
MaCle1 = TabCheval(1)
MaCle2 = CDate(TabCheval(2) & " 00:00:00.000")
MaCle3 = TabCourses(2)
With Gestion.RPerformances
.Index = "PrimaryKey"
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.Open("Performances", Gestion.Cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, ADODB.CommandTypeEnum.adCmdTableDirect)
'.Seek(MaCle, ADODB.SeekEnum.adSeekFirstEQ)
.Seek((MaCle1, MaCle2, MaCle3), ADODB.SeekEnum.adSeekFirstEQ)
If Gestion.RPerformances.EOF Then
.AddNew()
.Fields("Nom").Value = TabCheval(1)
.Fields("DatePerf").Value = CDate(TabCheval(2) & " 00:00:00.000")
End If
End With
Gestion.RPerformances.Fields("Lieu").Value = LCase(TabCheval(3))
Gestion.RPerformances.Fields("Dist").Value = CInt("0" & TabCheval(4))
Gestion.RPerformances.Fields("Gains").Value = CLng("0" & TabCheval(5))
Gestion.RPerformances.Fields("Partants").Value = CInt("0" & TabCheval(6))
Gestion.RPerformances.Fields("Corde").Value = TabCheval(7)
Gestion.RPerformances.Fields("Cordage").Value = TabCheval(8)
Gestion.RPerformances.Fields("Deferre").Value = TabCheval(9)
Gestion.RPerformances.Fields("Poid").Value = CSng("0" & TabCheval(10))
Gestion.RPerformances.Fields("Discipline").Value = TabCheval(11)
Gestion.RPerformances.Fields("TypeCourse").Value = TabCheval(12)
Gestion.RPerformances.Fields("Allocation").Value = CLng("0" & TabCheval(13))
Gestion.RPerformances.Fields("Place").Value = TabCheval(14)
Gestion.RPerformances.Fields("Cote").Value = CSng("0" & TabCheval(15))
Gestion.RPerformances.Fields("RedKDist").Value = TabCheval(16)
Gestion.RPerformances.Fields("DateModif").Value = Format(Now, "dd/mm/yyyy hh:mm")
Gestion.RPerformances.Update()
Gestion.RPerformances.Close()
Gestion.RPerformances = Nothing
'***
'*** SQLServer
'***
Gestion.RPerformances = New ADODB.Recordset
With Gestion.RPerformances
.Index = "PrimaryKey"
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.Open("Performances", Gestion.CnSQLS, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, ADODB.CommandTypeEnum.adCmdTableDirect)
'.Seek((TabCheval(1), TabCheval(2)), ADODB.SeekEnum.adSeekFirstEQ)
'.Seek(MaCle, ADODB.SeekEnum.adSeekFirstEQ)
.Seek((MaCle1, MaCle2, MaCle3), ADODB.SeekEnum.adSeekFirstEQ)
If Gestion.RPerformances.EOF Then
.AddNew()
.Fields("Nom").Value = TabCheval(1)
.Fields("DatePerf").Value = CDate(TabCheval(2) & " 00:00:00.000")
End If
End With
Gestion.RPerformances.Fields("Lieu").Value = LCase(TabCheval(3))
Gestion.RPerformances.Fields("Dist").Value = CInt("0" & TabCheval(4))
Gestion.RPerformances.Fields("Gains").Value = CLng("0" & TabCheval(5))
Gestion.RPerformances.Fields("Partants").Value = CInt("0" & TabCheval(6))
Gestion.RPerformances.Fields("Corde").Value = TabCheval(7)
Gestion.RPerformances.Fields("Cordage").Value = TabCheval(8)
Gestion.RPerformances.Fields("Deferre").Value = TabCheval(9)
Gestion.RPerformances.Fields("Poid").Value = CSng("0" & TabCheval(10))
Gestion.RPerformances.Fields("Discipline").Value = TabCheval(11)
Gestion.RPerformances.Fields("TypeCourse").Value = TabCheval(12)
Gestion.RPerformances.Fields("Allocation").Value = CLng("0" & TabCheval(13))
Gestion.RPerformances.Fields("Place").Value = TabCheval(14)
Gestion.RPerformances.Fields("Cote").Value = CSng("0" & TabCheval(15))
Gestion.RPerformances.Fields("RedKDist").Value = TabCheval(16)
Gestion.RPerformances.Fields("DateModif").Value = Format(Now, "dd/mm/yyyy hh:mm")
Gestion.RPerformances.Update()
Gestion.RPerformances.Close()
Gestion.RPerformances = Nothing
Exit Sub
ErrADO:
strErrMsg = "Erreur N° " & CStr(Err.Number) & " : " & Err.Description
Select Case Err.Number
' principaux codes d'erreurs impliquant ODBC
Case 3146, 3151, 3154, 3155, 3156, 3157, 3231, 3232, 3234, 3225, 3238, 3247, 3254
strErrMsg = strErrMsg & vbCrLf & vbCrLf &
">>> Erreurs complémentaires DAO :" & vbCrLf &
"======================"
'Récupération Erreur(s) driver ODBC via DAO
#Disable Warning BC42104 ' La variable est utilisée avant de se voir attribuer une valeur
For Each ErrX In DBEngine.Errors
#Enable Warning BC42104 ' La variable est utilisée avant de se voir attribuer une valeur
strErrMsg = strErrMsg & vbCrLf & Format(ErrX.Number, "00000") & " : " & ErrX.Description
Next
End Select
Console.WriteLine(strErrMsg)
Gestion.LogSQL += vbCrLf & " - EnregPerformance - Erreur N° " & CStr(Err.Number) & " : " & Err.Description
End Sub |
Partager