load the dateable from database.
then add the column
then loop thru the rows setting the column's calculated value.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using visual studio 2019. I have created a project. The project has winform. On the form, it has a datagridview component.
I am retrieving data from an sql database table and filling a datatable with it. The datatable is the datasource for the datagridview.
I want to add a column to the datagridview which contains calculated values. The sql table has a decimal field call occupancy. It is a decimal field. This decimal field needs to be processed to create a string of the format "00:00:00". I have a function created that takes the decimal value and returns the processes string, but I am unable to figure out how to :
dataTable1.Columns.Add("calc_occupancy",typeof(NVarChar),"whatevershouldgohere");
Any ideas greatly appreciated.
Thanks.
load the dateable from database.
then add the column
then loop thru the rows setting the column's calculated value.
Consider a computed column. Its best done in SSMS then query the table as you would any table.