momosan77
Messages postés47Date d'inscriptionlundi 17 mai 2010StatutMembreDernière intervention19 décembre 2011
-
5 avril 2011 à 08:42
momosan77
Messages postés47Date d'inscriptionlundi 17 mai 2010StatutMembreDernière intervention19 décembre 2011
-
5 avril 2011 à 15:06
Bonjour, actuellement en BTS d'informatique de gestion je dois obligatoirement développer différent application. L'application suivante est une gestion de stock de voiture ainsi que les réparation. Le problème rencontré est le plantage du programme lors du lancement de la classe réparer par une base SQL sur le code ci dessous.
Si quelqu'un peu m'aider si vous plait, Merci d'avance.
public partial class Reparer : Form
{
public static MySqlConnection obj;
public Reparer()
{
InitializeComponent();
}
void ReparerLoad(object sender, EventArgs e)
{
//ouverture base de donnee
string chcnx="database=voiture; Data Source=localhost;User id=root;Password=";
obj=new MySqlConnection(chcnx);
obj.Open();
MySqlCommand cmdSelect=MainForm.obj.CreateCommand();
cmdSelect.CommandText="select * from reparation";
MySqlDataReader resultat=cmdSelect.ExecuteReader();
while (resultat.Read())
{
domainUpDown1.Items.Add(resultat.GetValue(1));
}
resultat.Close();
MySqlCommand cmd1Select=MainForm.obj.CreateCommand();
cmd1Select.CommandText="select motif_reparation from reparation";
MySqlDataReader resultat1=cmd1Select.ExecuteReader();
while (resultat1.Read())
{
listBox1.Items.Add(resultat1.GetValue(1));
}
resultat.Close();
MySqlCommand cmd2Select=MainForm.obj.CreateCommand();
cmd2Select.CommandText="select piece from reparation";
MySqlDataReader resultat2=cmd2Select.ExecuteReader();
while (resultat2.Read())
{
listBox2.Items.Add(resultat2.GetValue(2));
}
resultat.Close();