Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why this code doesn't increment the number of Rows?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Why this code doesn't increment the number of Rows?
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01399434
Message ID:
01399434
Vues:
101
Hi everybody,

Why would this code
 if (_dtOrder.Rows.Count == 0) //Add a new order
            {
                _drOrder = _dtOrder.NewOrdersRow();
                _OrderBiz.InsertNewOrder(this._drOrder);
            }
don't change the _dtOrder.Rows.Count ? Should my _OrderBiz.InsertNewOrder method return back the datatable? Or may be I should pass it as a reference and insert.

I'm guessing this is completely wrong implementation
/// <summary>
        /// Insert new order
        /// </summary>
        /// <param name="dr">data row</param>
        /// <returns>ID of new record</returns>
        public int InsertNewOrder(OrdersDataSet.OrdersRow dr)
        {
            int NewOrderID;
            using (OrdersTableAdapter ta = new OrdersTableAdapter())
            {
                dr.OrderPk  = Guid.NewGuid();

                NewOrderID = (int)ta.InsertOrderRecord(dr.OrderPk);
            }
        
            return NewOrderID;
        }
Since I don't know "which" table it now inserted record to and how can I update my reference in the form.

Any ideas of how should I fix it?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform