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
| '***************************
'*** MISE A JOUR RECORDS ***
'***************************
Public Sub MISE_A_JOUR_RECORDS_BIGBAG(ByVal Numero_Lot As String, ByVal Numero_OF As String, ByVal Numero_BigBag As Integer, ByVal Qualite As Integer)
Dim Nombre As Integer
Dim Date_J As Date
Date_J = Now()
'*** General connection objects
Dim objConnection As Object
Dim objRecordset As Object
Dim sConnectionString As String
'*** Global Request variable
Dim sRequest As String
'*** General constant
Const adOpenStatic = 3
Const adOpenDynamic = 4
Const adLockOptimistic = 3
Const adUseClient = 3
On Error GoTo TRAP_Error
'*** Creation de la requette SQL en fonction du produit
sRequest = "SELECT * FROM Records_Produit_Fini WHERE ((NUM_LOT = '" & Numero_Lot & "') AND (NUM_OF = '" & Numero_OF & "') AND (NUMERO_BIGBAG = " & Numero_BigBag & "))"
'MsgBox sRequest
'*** Creation des objets ADODB
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
'*** Connection a la base de donnees
sConnectionString = "uid=" & [SUPERVISION.SQL.NOM_UTILISATEUR] & ";pwd=" & [SUPERVISION.SQL.MOT_DE_PASSE] & ";driver={SQL Server};server=" & [SUPERVISION.SQL.NOM_SERVEUR] & ";database=" & [SUPERVISION.SQL.NOM_DB] & ";dsn=''"
objConnection.Open sConnectionString
objRecordset.CursorLocation = adUseClient
objRecordset.Open sRequest, objConnection, adOpenStatic, adLockOptimistic
Nombre = 0
Do Until Not objRecordset.EOF
Nombre = Nombre + 1
Loop
'*** Ajout d'une ligne dans le RecordSet
objRecordset.Fields("Poids_Produit_Fini_1") = 60 '[SUPERVISION.Poids_En_Cours_BigBag]
objRecordset.Fields("Date_Fin") = DatePart("YYYY", Date_J) & "-" & DatePart("m", Date_J) & "-" & DatePart("d", Date_J) & " " & DatePart("h", Date_J) & ":" & DatePart("n", Date_J) & ":" & DatePart("s", Date_J) & ".000"
objRecordset.Fields("Qualite") = Qualite
'*** Mise a jour de la base de donnees
objRecordset.Update
'*** Fermeture du RecordSet
objRecordset.Close
If Not objRecordset Is Nothing Then
Set objRecordset = Nothing
End If
'*** Fermeture de la connection
If Not objConnection Is Nothing Then
objConnection.Close
Set objConnection = Nothing
End If
Exit Sub
TRAP_Error:
If Err.Number = -2147467259 Then
MsgBox "Cannot find the database " & sDBName
Else
MsgBox "You met an error by connecting database " & sDBName & "." & vbCrLf & "Error location: Mise à jours Big Bag. " & Err.Description
End If
End Sub |
Partager