Click here to Skip to main content
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 0:54am
asverka398
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 490
1 Gihan Liyanage 338
2 ChauhanAjay 180
3 Vinay Mistry 160
4 Sergey Alexandrovich Kryukov 138
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2014
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