Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this code doesn't increment the number of Rows?
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Why this code doesn't increment the number of Rows?
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01399434
Message ID:
01399434
Views:
100
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
Next
Reply
Map
View

Click here to load this message in the networking platform