Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1117 connectés 

  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  [C#] DataAdapter.Update() marche pô

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[C#] DataAdapter.Update() marche pô

n°1338037
Arjuna
Aircraft Ident.: F-MBSD
Posté le 03-04-2006 à 17:52:48  profilanswer
 

Je fais ça :
 

Code :
  1. public void UpdateShops(OleDbConnection cnx)
  2.  {
  3.   OleDbCommand cmd = cnx.CreateCommand();
  4.   cmd.CommandText = "soc";
  5.   cmd.CommandType = CommandType.TableDirect;
  6.   cmd.Prepare();
  7.   OleDbDataAdapter da = new OleDbDataAdapter();
  8.   da.SelectCommand = cmd;
  9.   da.UpdateCommand = cmd;
  10.   da.InsertCommand = cmd;
  11.   da.DeleteCommand = cmd;
  12.   DataTable dt = new DataTable();
  13.   da.Fill(dt);
  14.   foreach (XmlNode el in dom.DocumentElement.GetElementsByTagName("shop" ))
  15.   {
  16.    bool found = false;
  17.    foreach (DataRow dr in dt.Rows)
  18.    {
  19.     if (((decimal)dr["codsoc"]).ToString() == el.Attributes["codsoc"].Value)
  20.     {
  21.      dr["libut_soc"] = el.Attributes["libut_soc"].Value;
  22.      dr.AcceptChanges();
  23.      found = true;
  24.      break;
  25.     }
  26.    }
  27.    if (!found)
  28.    {
  29.     object[] vals = new object[2];
  30.     vals[0] = decimal.Parse(el.Attributes["codsoc"].Value);
  31.     vals[1] = el.Attributes["libut_soc"].Value;
  32.     dt.Rows.Add(vals);
  33.     dt.AcceptChanges();
  34.    }
  35.   }
  36.   dt.AcceptChanges();
  37.   da.Update(dt);
  38.  }


 
Ma table reste vide dans la base, alors que j'ai bien une nouvelle ligne au statut "Added" dans mon dt.
Je suppose que j'ai oublié un truc, mais quoi ? [:atari]


Message édité par Arjuna le 03-04-2006 à 17:57:34
mood
Publicité
Posté le 03-04-2006 à 17:52:48  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  [C#] DataAdapter.Update() marche pô

 

Sujets relatifs
radiobutton et selected qui marche po[PHP] Fonction mail() qui ne marche pas
Regex qui ne marche pas :@[RESOLU]Faire une gallerie de photo en HTML [SISI CA MARCHE] :)
css marche sous IE, pas sous firefox, que faire?[resolu] forcer telechargement pdf : ca marche, mais...
Saut de page, ca marche. Oui mais...Problème .htaccess il ne marche pas ?!!
scanér ne marche pas sous XPCréation d'executable sous VB qui ne marche pas : (
Plus de sujets relatifs à : [C#] DataAdapter.Update() marche pô


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR