Salut , sur un formulaire je souhaite faire un simple ajout dans une base de donnée e nutilisant une procédure stockée que voici :
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
create procedure ajoutProduit
  @titre as varchar(50),
  @soustitre as varchar(80),
  @auteur as varchar(60),
  @prix as decimal,
  @marge as decimal,
  @codeType as integer
as
  declare @id int
  select @id = (select code from Produit where titre=@titre and soustitre=@soustitre and auteur=@auteur and prix=@prix and marge=@marge )
 
  if @id is null
  begin
    insert into Produit(titre,soustitre,auteur,prix,marge,codeType,qtStock) values(@titre,@soustitre,@auteur,@prix,@marge,@codeType,0)
    return (0)
  end
  else
    return(1)
Et voici le 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
Private Sub CreerProduit_Click()
    Dim procStock As ADODB.Command
    Set procStock = CreateObject("ADODB.Command")
    procStock.ActiveConnection = CurrentProject.Connection
    procStock.CommandType = adCmdStoredProc
    procStock.CommandText = "ajoutProduit"
    Dim param As Parameter
    Dim titre As String
    Dim soustitre As String
    Dim auteur As String
    Dim prix As Double
    Dim marge As Double
    Dim codeType As Integer
 
 
 
 
    If IsNull(Me.titreAjout) Or IsNull(Me.auteurAjout) Or IsNull(Me.prixAjout) Or IsNull(Me.margeAjout) Then
        MsgBox ("des informations sont manquantes !")
 
    Else
         titre = Me.titreAjout.Value
         If IsNull(Me.soustitreAjout.Value) Then
         soustitre = ""
         Else
         soustitre = Me.soustitreAjout.Value
         End If
         auteur = Me.auteurAjout.Value
         prix = Me.prixAjout.Value
         marge = Me.margeAjout.Value
         codeType = Me.lesTypesAjout.Value
 
          ' déclarer le retour en premier et mettre une value arbitraire
          Set param = procStock.CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, , 1)
          procStock.Parameters.Append param
          Set param = procStock.CreateParameter("@titre", adVarChar, adParamInput, 50, Trim(StrConv(LCase(titre), vbProperCase)))
          procStock.Parameters.Append param
          Set param = procStock.CreateParameter("@soustitre", adVarChar, adParamInput, 80, Trim(StrConv(LCase(soustitre), vbProperCase)))
          procStock.Parameters.Append param
          Set param = procStock.CreateParameter("@auteur", adVarChar, adParamInput, 60, Trim(StrConv(LCase(auteur), vbProperCase)))
          procStock.Parameters.Append param
          Set param = procStock.CreateParameter("@prix", adDecimal, adParamInput, 10, prix)
          procStock.Parameters.Append param
          Set param = procStock.CreateParameter("@marge", adDecimal, adParamInput, 10, marge)
          procStock.Parameters.Append param
          Set param = procStock.CreateParameter("@codeType", adInteger, adParamInput, , codeType)
          procStock.Parameters.Append param
          procStock.Execute
          If procStock.Parameters("RETURN_VALUE").Value = 1 Then
            MsgBox ("Ajout impossible")
          Else
 
            MsgBox ("Ajout effectué")
            titreAjout.Value = ""
            soustitreAjout.Value = ""
            auteurAjout.Value = ""
            prixAjout.Value = ""
            margeAjout.Value = ""
 
          End If
 
    End If
End Sub

Enfin dès que je clique sur le bouton de création, il me renvoie l'erreur suivante:

erreur d'execution '-2147467259 : (80004005)':

précision non valide



Et en cliquant sur débogage il pointe sur " procStock.execute"

J'ai testé les valeurs des variables à recuperer, pas de probleme sur ca.
La procédure fonctionne aussi très bien sur SQL serveur.


Si vous pouviez m'eclairer merci .