Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update DataTable in Local
Message
De
16/05/2008 03:20:32
 
 
À
15/05/2008 22:47:37
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01317532
Message ID:
01317561
Vues:
7
>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?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform