1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Function MajSql(LCT As String, Oper As String) As Boolean
Const User = "----", Base = "GPAO_V8_TEST", PassWord = "----", Server = "---------"
Const adVarChar = 200, adInteger = 3
On Error GoTo fin
With CreateObject("ADODB.Command")
.ActiveConnection = "Provider=SQLOLEDB.1;Password=" & PassWord & ";Persist Security Info=True;User ID=" & User & ";Initial Catalog=" & Base & ";Data Source=" & Server
.CommandType = 1
.CommandText = "Update [LCTE] Set [VarAlphaUtil4]=@Oper Where [CodeLancement]=@LCT"
.Parameters.Append CreateObject("ADODB.Command").CreateParameter("@Oper", adVarChar, 1, 50, Oper)
.Parameters.Append CreateObject("ADODB.Command").CreateParameter("@LCT", adVarChar, 1, 50, LCT)
.Execute
MajSql = True
End With
fin:
On Error GoTo 0
End Function
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
If Target.Column = 7 Then
If Trim("" & Cells(Target.Row, "F")) <> "" Then MajSql Cells(Target.Row, "F"), Trim(Target)
End If
End If
End Sub |
Partager