Click here to Skip to main content
11,480,148 members (68,759 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have make insert command and it work well but I need and Update Methods but I can't how can I make it
Insert methods is so
<
int fatID = -1;
                using (var db = new RestDBDataContext())
                {
                    var fat = new Faturat() { PuntoriID = 1, Data = dtData.Value, Klienti = cbKlienti.Text };
                    db.Faturats.InsertOnSubmit(fat);
                    db.SubmitChanges();
                    fatID = fat.ID;
                    decimal total = 0;
                    foreach (DataRow row in dtDetaletFatura.Rows)
                    {
                        var fd = new FaturatDetalet();
                        fd.ArtikulliID = (int)row["ArtikulliID"];
                        fd.Cmimi = (decimal?)row["Cmimi"];
                        fd.Sasia = (decimal?)row["Sasia"];
                        fd.Njesia = row["Njesia"].ToString();
                        fd.FaturaID = fatID;
                        total += fd.Cmimi.GetValueOrDefault(0) * fd.Sasia.GetValueOrDefault(0);
                        db.FaturatDetalets.InsertOnSubmit(fd);
 
                    }
                    fat.Shuma = Convert.ToDecimal(txtTotali.Text);
                    db.SubmitChanges()
;
Posted 17-Feb-13 1:54am
asverka430
Comments
Gittu Dash at 17-Feb-13 8:58am
   
Have you tried using SubmitChanges() inside foreach loop ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 215
2 Richard MacCutchan 100
3 F-ES Sitecore 75
4 DamithSL 65
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100