Returning a column value from a table in dataset
dsDiscounts.Tables[1].Columns[0]
returns column definition (data type, caption, etc defined by DataColumn instance). Of course column definition conversion to integer fails.
What you need is cell value from some row of table (assume first row). You should use Rows
collection to get access to table rows. After you get required DataRow
by it's index, you can access cells in row by index, column name, column object, etc. E.g. getting first row's cell value by column name:
dsDiscounts.Tables[1].Rows[0]["CONTACT_ID"]
Try this
int Contract_id = Convert.ToInt32(dsDiscounts.Tables[1].Rows[0]["CONTACT_ID"]);