Click here to Skip to main content
12,405,700 members (63,840 online)
Rate this:
 
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
asverka484
Comments
Gittu Dash 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2016
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