Bonjour à tous,
je suis débutante en C# , je suis entrain de développer un petit formulaire et je n'arrive pas à envoyer les données vers la BD sql

donc voilà j'ai une table:

incident (Id_Incident,#Login, Type,Priorité,Objet,Description,Date_Ouverture, Date_CLôture, Etat)
user(login, passwd, profil)

Date_Ouverture: doit prendre la date systeme
Date_CLôture; doit prendre null pour le moment
Etat; doit prendre 'Ouvert'

code de ma procédure stockée pour insérer les champs dans la table incident:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
Create Procedure InsertIncident  ( @Id_Incident int, 
				@Login varchar(50), 
				@Type varchar(50),
				@Priorite varchar(50),
				@Objet varchar(50),
				@Description varchar(50),
				@Date_Ouverture date,
				@Date_cloture date,
                                @Etat varchar(50)) 
as 
Insert into Incident (Id_Incident, Login, Type, Priorite, Objet,Description,Date_Ouverture, Date_cloture, Etat) 
values(@@identity,@Login,@Type,@Priorite,@Objet,@Description,CURRENT_TIMESTAMP,NULL,'Ouvert')

le code de ma fonction C#

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
public static DataSet AjoutIncident(int Id_Incident, String Login,String Type, String Priorite, String Objet, String Description,DataSetDateTime Date_Ouverture, DataSetDateTime Date_Cloture, String Etat)
        {
            SqlParameter[] AttributTab = new SqlParameter[] 
             {
 
                new SqlParameter("@Login", Login),
                new SqlParameter("@Type", Type),
                new SqlParameter("@Priorite", Priorite),
                new SqlParameter("@Objet", Objet),
                new SqlParameter("@Description", Description)
               };
 
            DataSet ds = new DataSet();
            SqlConnection connexion;
            try
            {
                connexion = new SqlConnection("Server=.\\SQLExpress; AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\test1607.mdf;Database=test1607; Trusted_Connection=Yes;");
                connexion.Open();
 
                SqlCommand cmd = new SqlCommand("InsertIncident", connexion);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddRange(AttributTab);
                cmd.CommandTimeout = 3600;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
            }
            catch (Exception x)
            {
                string ex = x.Message;
            }
            return ds;
        }
appel de la fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
private void button2_Click(object sender, EventArgs e)
        {
            AjoutIncident(textBox3.Text, comboBox1.Text, comboBox2.Text, textBox1.Text, textBox2.Text);
        }
Quelqu'un pourrait m'aider!
Merci d'avance.