Bonjour. Je dois réaliser pour ma boite un logiciel qui enregistre des données sur la base de données au moment où il se ferme. Le problème est que je n'arrive pas à trouver le bon code (je n'ai pas appris à programmer, et je n'ai pas le temps de le faire si je veux finir ce projet à temps).
Voici l'ancien code qui marchait jusque la :
Le reset des tables est obligatoire car sinon je crois que la copie du DS dans la base crée une erreur (si le matériel est déjà entré et qu'on le remet sans vider la base).
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 //Reset de toutes les tables //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM materiels", Connection); //MyAdapter.Update(DS, "materiels"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM plots", Connection); //MyAdapter.Update(DS, "plots"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM reservations", Connection); //MyAdapter.Update(DS, "reservations"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM patrons", Connection); //MyAdapter.Update(DS, "patrons"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM j_MatPlot", Connection); //MyAdapter.Update(DS, "j_MatPlot"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM j_ResaPlot", Connection); //MyAdapter.Update(DS, "j_ResaPlot"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM j_ResaMat", Connection); //MyAdapter.Update(DS, "j_ResaMat"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM j_ResaPatron", Connection); //MyAdapter.Update(DS, "j_ResaPatron"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM j_ResaUser", Connection); //MyAdapter.Update(DS, "j_ResaUser"); //MyAdapter.InsertCommand = new MySqlCommand("DELETE FROM global", Connection); //MyAdapter.Update(DS, "global"); //load.Avancer(1); //Copie du DS dans la Base //MyAdapter = new MySqlDataAdapter("SELECT * FROM materiels", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "materiels"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM plots", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "plots"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM reservations", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "reservations"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM patrons", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "patrons"); //load.Avancer(1); //MyAdapter = new MySqlDataAdapter("SELECT * FROM j_MatPlot", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "j_MatPlot"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaPlot", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "j_ResaPlot"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaMat", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "j_ResaMat"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaPatron", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "j_ResaPatron"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaUser", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "j_ResaUser"); //MyAdapter = new MySqlDataAdapter("SELECT * FROM global", Connection); //MyBuilder = new MySqlCommandBuilder(MyAdapter); //MyAdapter.Update(DS, "global");
Voici le nouveau code qui doit être mis en place :
Si vous pouvez m'aider à trouver ce qui ne va pas. Merci.
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 //Copie du DS dans la Base //nouveau codage MyAdapter = new MySqlDataAdapter("SELECT * FROM materiels", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE materiels SET Nom , Fournisseur, Fabriquant, Gamme, Famille, Annee, NumInventaire, NumSerie, Remarques"); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO materiels (Nom, Fournisseur, Fabriquant, Gamme, Famille, Annee, NumInventaire, NumSerie, Remarques) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM plots", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE plots SET identifiant, emplacement, remarques "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO plots (identifiant, emplacement, remarques) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM reservations", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE reservations SET Debut, Fin, Utilite, Code, Remarques, CheckSupport, RemarquesSupport, Cloture, Annule, RemarquesFinReservation"); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO reservations (Debut, Fin, Utilite, Code, Remarques, CheckSupport, RemarquesSupport, Cloture, Annule, RemarquesFinReservation) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM patrons", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE patrons SET Nom, Prenom, Fonction "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO patrons (Nom, Prenom, Fonction) "); load.Avancer(1); MyAdapter = new MySqlDataAdapter("SELECT * FROM j_MatPlot", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE j_MatPlot SET PlotID, MatID "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO j_MatPlot (PlotID, MatID) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaPlot", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE j_ResaPlot SET PlotID, ResaID "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO j_ResaPlot (PlotID, ResaID) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaMat", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE j_ResaPlot SET PlotID, ResaID "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO j_ResaPlot (PlotID, ResaID) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaPatron", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE j_ResaPatron SET PrenomID, NomID, ResaID "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO j_ResaPatron (PrenomID, NomID, ResaID) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM j_ResaUser", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE j_ResaUser SET Prenom, Nom, ResaID "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO j_ResaUser (Prenom, Nom, ResaID) "); MyAdapter = new MySqlDataAdapter("SELECT * FROM global", Connection); MyBuilder = new MySqlCommandBuilder(MyAdapter); MyAdapter.UpdateCommand = new MySqlCommand("UPDATE global SET NumReservation, NumMatAdd "); MyAdapter.InsertCommand = new MySqlCommand("INSERT INTO global (NumReservation, NumMatAdd) ");
Partager