sqlite add sync data

i got values at sqlite and i just want to add new sync values like

xml file vals;
a 1
b 2
c 3

saves sqlite db

and a new values add to xml

a 1
b 2
c 3
d 4

hows that possible to add only d4 ? update or insert?
thanks

Posts

  • StevenTheEvenStevenTheEven SEMember ✭✭✭

    update

  • HarshadcseHarshadcse USMember ✭✭✭

    @haluk‌ - You have to use INSERT Statement.

    Update - The UPDATE statement is used to update existing records in a table.

    Insert - The INSERT INTO statement is used to insert new records in a table.

  • HalukmyHalukmy TRMember ✭✭
    edited February 2014
      var data = from x in doc.Descendants("item") select new  {
                      Personel = x.Element("Personel").Value,
                      Sube = x.Element("Sube").Value,
                      VerilenTarih = x.Element("VerilenTarih").Value,
                      GorevVeren = x.Element("GorevVeren").Value,
                      Gorev = x.Element("Gorev").Value,
                      GorevMesaj = x.Element("GorevMesaj").Value,
                      Rapor = x.Element("Rapor").Value,
                      RaporTarihi = x.Element("RaporTarihi").Value,
                      Gonderme = x.Element("Gonderme").Value,
                      EmirVeren = x.Element("EmirVeren").Value,
                      Emir = x.Element("Emir").Value,
                      EmirMesaj= x.Element("EmirMesaj").Value,
                      Goruldu= x.Element("Goruldu").Value,
                Tarih= x.Element("Tarih").Value,
                ImgUrl = x.Element("Img").Value
                   };
                   foreach (var p in data)
                   {
                      sqlCom.CommandText =  "INSERT INTO PERSONEL (Personel, Sube, VerilenTarih, GorevVeren , GorevBaslik , GorevIcerik , Rapor, RaporTarihi, Gonderme,  EmirVeren , EmirBaslik , EmirIcerik , Goruldu  , Tarih ,ImgUrl) VALUES (@pers,@sube,@vtarih,@gveren,@gbaslik,@gicerik,@rapor,@raportarihi,@gonder,@everen,@ebaslik,@eicerik,@goruldu,@tarih,@imgurl)";
                      sqlCom.Parameters.Add (new SqliteParameter ("@pers", p.Personel));
                      sqlCom.Parameters.Add (new SqliteParameter ("@sube", p.Sube));
                      sqlCom.Parameters.Add  (new SqliteParameter("@vtarih", p.VerilenTarih));
                      sqlCom.Parameters.Add (new SqliteParameter ("@tarih", p.Tarih));
                      sqlCom.Parameters.Add (new SqliteParameter ("@everen", p.EmirVeren));
                      sqlCom.Parameters.Add (new SqliteParameter ("@ebaslik", p.Emir));
                      sqlCom.Parameters.Add (new SqliteParameter ("@eicerik", p.EmirMesaj));
                      sqlCom.Parameters.Add (new SqliteParameter ("@gveren", p.GorevVeren));
                      sqlCom.Parameters.Add (new SqliteParameter ("@gbaslik", p.Gorev));
                      sqlCom.Parameters.Add (new SqliteParameter ("@gicerik", p.GorevMesaj));
                      sqlCom.Parameters.Add(new SqliteParameter("@rapor", p.Rapor));
                      sqlCom.Parameters.Add(new SqliteParameter("@raportarihi", p.RaporTarihi));
                      sqlCom.Parameters.Add(new SqliteParameter("@imgurl", p.ImgUrl));
                      sqlCom.Parameters.Add(new SqliteParameter("@gonder", p.Gonderme));
                      if(p.Goruldu == "True")
                         sqlCom.Parameters.Add (new SqliteParameter ("@goruldu", true));
                      else
                         sqlCom.Parameters.Add (new SqliteParameter ("@goruldu", false));
    
    
    
    
                      sqlCom.ExecuteNonQuery ();
    

    this is insert

    but when i do this, adds every row aagain and again

  • StevenTheEvenStevenTheEven SEMember ✭✭✭

    IF you use insert it obviously will insert and not update an allready existing row in you table. If you want to update an allready existing row you use update.

Sign In or Register to comment.