Bonjour

voici mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Function Msj_Data_Courbe(Byval Des,Nr_Courbe)
 
Dim objConnection, objCommand, objRecordset, strConnectionString
Dim strSQL, lngCount , lngValue
Dim L,V,T,D,E,N
 
Set L = HMIRuntime.Tags("LABEL")
Set V = HMIRuntime.Tags("VISIBLE")
Set T = HMIRuntime.Tags("TAGNAME")
Set D = HMIRuntime.Tags("DES")
Set E = HMIRuntime.Tags("ETAT_SQL")
Set N = HMIRuntime.Tags("NAME")
 
E.Value = "en cours"
E.write
 
 
strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
'---------------------- SQL ---------------
 
 
strSQL = "SELECT WINCC_COURBE.Description, WINCC_COURBE.Tag, WINCC_COURBE.LABEL, WINCC_COURBE.Visible,WINCC_COURBE.Courbes"
StrSQL = StrSQL + " FROM WINCC_COURBE "
StrSQL = StrSQL + " WHERE WINCC_COURBE.Description='"
StrSQL = StrSQL + Des +"' And WINCC_COURBE.Nr_Courbes= " 'Parametre
StrSQL = StrSQL + Nr_Courbe +";"  'Parametre de la fonction
strSQL = Replace (strSQL,vbNullChar ,"") ' suprimer les carectere null
 
 
 
T.Value ="11111111111111"
T.Write
 
 
objCommand.CommandText = strSQL
Msj_debug(Strsql)
 
Set objRecordset = objCommand.Execute
lngCount = 0
lngCount = objRecordset.Fields.count
'objRecordset.
'Msj_debug("Lire 01")
 
 
T.Value = "222222"
T.write
 
'If (LngCount = vbNullChar)then
'    T.Value = "NULL"
'    T.write
 
'End If
 
 
'MISE AJOUR DE LA VARIABLE
If (lngCount>0) Then        
   D.Value = objRecordset.Fields(0).Value
   T.Value = objRecordset.Fields(1).Value
   L.Value = objRecordset.Fields(2).Value	
   V.value = objRecordset.Fields(3).Value   
   N.value = objRecordset.Fields(4).Value   
   E.Value = "ok"
 
   Else
   T.Value = "&"
   V.Value = False
   T.Value = "&"
   D.Value = "&"
   N.value = "&"
   E.Value = "0 lignes"
 
 
End If
L.Write
V.Write
T.Write
D.Write
N.Write
E.write
 
End Function
Lorsque ma fonction trouve un ligne, tous se passe bien.

Mais si ma fonction ne trouve rien, il plante avant l'instruction
Je ne sais pas la valeur de ma variable LngCount quand il trouve rien.

Quel comparaison, je pourrais faire ?