Bonjour à tous,
étant débutant aussi bien en langage SQL qu'en C# je fais appel à votre aide pour m'éclairer sur un problème.
Je cherche à faire une petite application permettant de stocker des connaissances (fonctions, docs, tips...) dans une BDD puis de venir rechercher et consulter ces données à l'aide d'une procédure stockée selon les paramètres d'entrée définis.
La procédure fonctionne comme je le souhaite mais je ne comprends pas, malgré de nombreuses recherches sur Internet, comment l'appeler - lui passer les paramètres - voir le résultat depuis une application Windows form C# ne contenant qu'un simple bouton pour le moment (le code est situé dans l'événement clic du bouton).

*procédure stockée*
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
 
ALTER PROCEDURE [dbo].[G4HDC_ConsultationSp](
@typologie nvarchar(50) = NULL,
@categorie nvarchar(50)= NULL,
@libelle nvarchar(200)= NULL,
@description nvarchar(MAX)= NULL,
@createur nvarchar(50)= NULL)
 
AS
BEGIN 
 
 
	SELECT * 
	FROM  HDC_connaissance
        WHERE typologie  LIKE isnull('%'+@typologie+'%',typologie) and    categorie LIKE isnull('%'+@categorie+'%',categorie) and libelle LIKE  isnull('%'+@libelle+'%',libelle) 
	      and description LIKE isnull('%'+@description+'%',description) and createur LIKE isnull('%'+@createur+'%',createur)
	ORDER BY typologie,categorie,createur,libelle,description
 
 
END
*code (C#) de l'événement "clic" du bouton*
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
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
 
            SqlConnection cnx;
            cnx = new SqlConnection("Data Source=****;Initial Catalog=****;User Id=****;Password=****");
 
            SqlCommand maCommande;
            maCommande = new SqlCommand();
            maCommande.CommandText = "G4HDC_ConsultationSp";
            maCommande.CommandType = CommandType.StoredProcedure;
            maCommande.Connection = cnx;
 
            SqlParameter parm1 = new SqlParameter("@typologie", SqlDbType.NVarChar);
            parm1.Value = null;
            parm1.Direction = ParameterDirection.InputOutput;
            maCommande.Parameters.Add(parm1);
 
            SqlParameter parm2 = new SqlParameter("@categorie", SqlDbType.NVarChar);
            parm2.Value = null;
            parm2.Direction = ParameterDirection.InputOutput;
            maCommande.Parameters.Add(parm2);
 
            SqlParameter parm3 = new SqlParameter("@libelle", SqlDbType.NVarChar);
            parm3.Value = null;
            parm3.Direction = ParameterDirection.InputOutput;
            maCommande.Parameters.Add(parm3);
 
            SqlParameter parm4 = new SqlParameter("@description", SqlDbType.NVarChar);
            parm4.Value = "écart";
            parm4.Direction = ParameterDirection.InputOutput;
            maCommande.Parameters.Add(parm4);
 
            SqlParameter parm5 = new SqlParameter("@createur", SqlDbType.NVarChar);
            parm5.Value = null;
            parm5.Direction = ParameterDirection.InputOutput;
            maCommande.Parameters.Add(parm5);
 
            SqlParameter parm6 = new SqlParameter("@date_creation", SqlDbType.DateTime);
            parm6.Value = null;
            parm6.Direction = ParameterDirection.Output;
            maCommande.Parameters.Add(parm6);
 
            SqlParameter parm7 = new SqlParameter("@emplct_fichier", SqlDbType.NVarChar);
            parm7.Value = null;
            parm7.Direction = ParameterDirection.Output;
            maCommande.Parameters.Add(parm7);
 
            cnx.Open();
            SqlDataReader Rdata;
            Rdata = maCommande.ExecuteReader();
            cnx.Close();
 
            MessageBox.Show(parm1.Value.ToString());
 
        }
    }
}
Dans cet exemple, je passe la valeur "écart" à mon paramètre parm4 (InputOutput) et je veux que mon paramètre parm1 (InputOutput) s'affiche en sortie avec le résultat de la procédure stockée. Mais lorsque je lance le débogage et que je clic sur le bouton rien ne se passe et une erreur "InvalidOperationException n'a pas été gérée - String[0] : la propriété Size a une taille non valide, 0." apparaît.

Merci d'avance pour votre aide, vos pistes.