private void btnImport_Click(object sender, System.EventArgs e) { //Ouverture de la fenetre de dialogue openFileDialog.Filter = "Fichier *.csv (*.csv)|*.csv"; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } StreamReader sr = File.OpenText(openFileDialog.FileName); string numero; string[] cols; string oldnumero; string datefacturation = ""; //Tant que je suis pas en fin de fichier while(sr.Peek()!= -1) { sr.ReadLine(); sr.ReadLine(); cols = sr.ReadLine().Split(';'); // Initialisation des variables numero = cols[6]; oldnumero = cols[6]; while(numero != oldnumero) //Boucle d'import dans la base { datefacturation = cols[1].Substring(10, 4); //datefacturation = datefacturation.Substring(10,4); MessageBox.Show(datefacturation); String sql = string.Format("Insert into Sim.T_Facturation2 (McuCode,Facturation)VALUES({0},{1})", cols[6], datefacturation); try { myCon.ExecuteNonQuery(sql); } catch (Exception ex) { myLog.LogError(ex.Message, ex.Source); } } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question