Bonjour,
J'aurais voulu évalué le temps en millisecondes de mes requêtes sql
Ne travaillant pas sur le serveur directement
J'utilise un timer d'intervalle 1ms, je le start avant la requête
Dans le timer Tick j'incrémente un integer global
Et quand j'affiche après la requête le résultat de i, il me met 0
J'ai essayer avec un application.doevents() mais pas de meilleurs résultats
ci-joint le code
Merci à vous,
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 Private i As Integer Private Odbc_Connex As New OdbcConnection("DSN=B.D. TRANSITAINER") Private Function Check_Containers(ByVal sSerial As String, ByVal Sql_Num As Integer) Dim sfContainers() As String Dim i As Integer Dim Odbc_C As OdbcCommand Dim Odbc_A As OdbcDataAdapter Dim Odbc_Ds As DataSet If Sql_Num = 0 Then Odbc_C = New OdbcCommand("SELECT ncontainer FROM todcn WHERE serial_todg = '" + sSerial + "';", Odbc_Connex) Odbc_A = New OdbcDataAdapter(Odbc_C) Odbc_Ds = New DataSet Odbc_A.Fill(Odbc_Ds) ElseIf Sql_Num = 1 Then Odbc_C = New OdbcCommand("SELECT ncontainer FROM tdocn WHERE serial_tdoco = '" + sSerial + "';", Odbc_Connex) Odbc_A = New OdbcDataAdapter(Odbc_C) Odbc_Ds = New DataSet Odbc_A.Fill(Odbc_Ds) Else sfContainers = New String(0) {""} Return sfContainers End If If Check_Empty(Odbc_Ds) = 0 Then sfContainers = New String(0) {""} Return sfContainers Else If Check_space(Odbc_Ds.Tables(0).Rows(0).Item(0)) = "---" Then sfContainers = New String(0) {} sfContainers(0) = "Mercancia en bodega" Else sfContainers = New String(Odbc_Ds.Tables(0).Rows.Count - 1) {} i = Odbc_Ds.Tables(0).Rows.Count For j As Integer = 0 To Odbc_Ds.Tables(0).Rows.Count - 1 sfContainers(j) = Odbc_Ds.Tables(0).Rows(j).Item(0) Next End If Return sfContainers End If End Function Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim scontainers() As String Timer1.Start() scontainers = Check_Containers("70023", 1) 'existe,méthode avec todg MsgBox(i) For Each element As String In scontainers MsgBox(":" + element + ":") Next End Sub Private Function Check_Empty(ByVal Data_Set As Data.DataSet) If Data_Set.Tables(0).Rows.Count = 0 Then Return 0 Else Return 1 End If End Function Private Function Check_space(ByVal sChaine As String) 'Ok le 30/10/07 'Efface les espaces en trop en début et en fin de chaine de caractère Dim sChaine1 As String = sChaine If sChaine1.StartsWith(" ") Then sChaine1 = sChaine1.Remove(sChaine1.IndexOf(" "), 1) Return Check_space(sChaine1) Else If sChaine1.EndsWith(" ") Then sChaine1 = sChaine1.Remove(sChaine1.LastIndexOf(" "), 1) Return Check_space(sChaine1) Else Return sChaine End If End If End Function Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick i = i + 1 End Sub
Partager