SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Other Development Tools
 How to update mutiple data into sql server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hueikar
Starting Member

1 Posts

Posted - 06/22/2012 :  06:09:35  Show Profile  Reply with Quote
I am using window phone7 to insert data into sql server
and using below coding to get shopping cart list at listbox.

public List<Order> FindOrder(string custemail, string orderstatus)
{
   var findorder = from r in order.Orders 
                   where (r.CustEmail  == custemail && r.OrderStatus == orderstatus ) 
                   select r;
   return findorder.ToList();
}

public pgShopCart()
{    
    var obj = App.Current as App;
    custemail = obj.custEMAIL;
    string orderstatus = "Pending";
    proxy.FindOrderCompleted += new EventHandler<FindOrderCompletedEventArgs>(proxy_FindOrderCompleted);
    proxy.FindOrderAsync(custemail, orderstatus);
}

void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
    ListBox1.ItemsSource = e.Result;
}


After that I want to update the orderId status become "success" but I am only able to update 1 row only by using assign listbox1.itemsource into observable collection.

void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
    ListBox1.ItemsSource = e.Result;
    ObservableCollection<Order> Orders = this.ListBox1.ItemsSource as ObservableCollection<Order>;

    foreach (Order order in Orders)
    {
        orderid = order.OrderID;
    } 
}


and this to update row:

public void UpdateOrderStatus(int orderid, string orderstatus, string paymentdate)
{
    Order data = order.Orders.Single(p => p.OrderID == orderid);
    data.OrderStatus = orderstatus;
    order.SubmitChanges();
}

private void btnPay_Click(object sender, RoutedEventArgs e)
{
    proxy.UpdateOrderStatusCompleted += new EventHandler<UpdateOrderStatusCompletedEventArgs>(proxy_UpdateOrderStatusCompleted);
    proxy.UpdateOrderStatusAsync(orderid, orderstatus);
}


Any idea to edit my coding for update multiple rows into database?

afrika
Flowing Fount of Yak Knowledge

Nigeria
2706 Posts

Posted - 10/14/2012 :  11:38:06  Show Profile  Reply with Quote
Though this is very late.

Instead of using LINQ, why not pass the variables to a stored procedure and let it easily do the work for you.

Best wishes

Edited by - afrika on 10/14/2012 11:38:33
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000