Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 How to update mutiple data into sql server

Author  Topic 

hueikar
Starting Member

1 Post

Posted - 2012-06-22 : 06:09:35
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
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2012-10-14 : 11:38:06
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
Go to Top of Page
   

- Advertisement -