Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update DataTable in Local
Message
From
16/05/2008 03:20:32
 
 
To
15/05/2008 22:47:37
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01317532
Message ID:
01317561
Views:
6
>How to update dataTable specify row?
>
>eg. if i have dataTable which have 2 datacolumn :customerId,invoiceAmt
>
>i want update :
>invoiceAmt = invoiceAmt + new Invoice Amt where customerId = 'C001'
>
>Thanks

Well... the quick answer is:
DataTable dt = new DataTable();
dt.Columns.Add("customerId", typeof(string));
dt.Columns.Add("invoiceAmt", typeof(double));
dt.Rows.Add("C001", 123.01);
dt.Rows.Add("C002", 123.11);
dt.Rows.Add("C001", 123.21);
dt.Rows.Add("C003", 123.31);
dt.Rows.Add("C001", 123.41);
dt.Rows.Add("C004", 123.51);
foreach (DataRow row in dt.Rows)
  {
  if ((string)row["customerId"]=="C001")
    {
    (row["invoiceAmt"]) = (Double)(row["invoiceAmt"]) + 100;
    }
    Console.WriteLine((string)row["customerId"] + " " + row["invoiceAmt"].ToString());
  }
But I'm not at all sure if that is exactly what you need. Are you trying to set a bunch of records or just one?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform