Bonjour,

Je suis nouveau dans le forum, je fais des calculs sur des champs mails il m'affiche l'erreur suivante :

l'opérateur '*' n'est pas défini pour le type 'dbnull' et le type double

veuillez maidez a corriger l'erreur je vous prie
jai mis la partie en gras qui renvoie lerreur
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
  Call connexion()
        Dim vnbpiece As Integer = 0
        Dim vnat As String = ""
        Dim vannee As Integer = 0
        Dim mntanP As Double = 0
        Dim mntanAP As Double = 0
        Dim typProprio As String = ""
        cmd.CommandText = "select * from contribuable c,avoirLocal al,local l where c.numcont=al.numcont and al.numloc=l.numloc and c.numcont='" & txtNumero.Text & "'"
        cmd2.CommandText = "select sum('" & vnbpiece & "' * pu *12) as [Montant a Paye] from nature where nature='" & vnat & "' and annee<='" & vannee & "'"
        cmd3.CommandText = "select sum( montant ) as [Montant Payé] from contribuable c,avoirLocal al,payements p where c.numcont=al.numcont and c.numcont=p.numcont and al.numloc='" & TextBox2.Text & "' and c.numcont='" & txtNumero.Text & "' and modePay='local'"
        Try
            cnx.Open()
            li = cmd.ExecuteReader
            If li.Read Then
                txtnom.Text = li(1)
                txtPre.Text = li(2)
                TextBox1.Text = li(3)
                txtPro.Text = li.GetString(4)
                txtAdresseEnre.Text = li.GetString(5)
                txtTel.Text = li.GetString(6)
                cmbSexe.Text = li.GetString(7)
                Cmbsit.Text = li.GetString(8)
                txtEmail.Text = li.GetString(9)
                Txtnationnalite.Text = li.GetString(10)
                vnat = li.GetString(15)
                vnbpiece = li.GetValue(19)
                vannee = li.GetValue(13)
            End If
            li.Close()
            lire = cmd2.ExecuteReader
            If (lire.Read()) Then
                If (typProprio = "PROPRIETAIRE") Then
                    mntanAP = lire.GetValue(0) * 0.1
                    Exit sub
                Else
                    mntanAP = lire.GetValue(0) * 0.15
                End If
                Exit Sub
            End If
            lire.Close()
            lir = cmd3.ExecuteReader
            If (lir.Read()) Then
                mntanP = lir.GetValue(0)
            Else
                mntanP = 0
            End If
            If (mntanAP > mntanP) Then
                Lblmontant.Text = mntanAP - mntanP
                Lblrestpayer.Text = mntanAP - mntanP
            ElseIf (mntanAP < mntanP) Then
                Lblmontant.Text = 0
                Label15.Text = "En Avance de"
                Lblrestpayer.Text = mntanP - mntanAP
            Else
                Lblmontant.Text = 0
                Lblrestpayer.Text = mntanP - mntanAP
                Exit Sub
            End If
            lir.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub