0

I am using visual studio 2008(C#) as front end and ms access as back end In data table there are two columns as 1.Rate and 2.VAT. I want to perform add operation on this columns values and show the addition in the third column in same data table. I am retrieving these two columns from database into data table.

Please help me in this situation..

Thanks & Regards,

chirag
  • 57
  • 1
  • 9
  • DataTable.Rows.Add("ComputedColumn"). Foreach (DataRow row in DataTable.Rows) { row.["ComputedColumn"].Value = (int)row.["1.Rate"].Value + (int)row.["2.VAT"].Value)} ; <- Are you searching for something like this? – Dieter B Apr 21 '16 at 09:10

1 Answers1

0

Try this.

dt.Columns.Add("NewColumn", typeof(System.Decimal));

foreach(DataRow row in dt.Rows)
{
    //need to set value to NewColumn column
    row["NewColumn"] =  Convert.ToDecimal( row["Rate"].ToString()) + Convert.ToDecimal(row["VAT"].ToString());
}
  • I am getting this error=> Error 1 The call is ambiguous between the following methods or properties: 'System.Math.Round(double, int)' and 'System.Math.Round(decimal, int)' on this line of code=> var ratewidoutax = Math.Round((Convert.ToInt32(txtProductcode.Text)) - (Convert.ToInt32(Itemtax)), 2); how can I solve this??? – chirag Apr 22 '16 at 06:12
  • Refer this link.http://stackoverflow.com/questions/771825/c-sharp-the-call-is-ambiguous-between-the-following-methods-or-properties-syst – Ponmani Chinnaswamy Apr 22 '16 at 07:51
  • I want to an Integer Id number in text box. And when I click on button, I want to auto increment that Id by one and so on..., in web application. Is this possible?? – chirag May 05 '16 at 11:23