I am new to C# i would like to know how do i retrieve an integer value from the database and store it in a variable.
After that i need to use this value to add another integer that is already done and store it back into the database.
I have searched many methods but most of the methods that were given stores it in a data grid view but i want to do the calculation without displaying.
SqlDataAdapter sql1 = new SqlDataAdapter("Select finaldays from LeaveTest where Id = '" + comboBox1.SelectedText + "'", con);//it will take from the selection of combobox
DataTable dt = new DataTable();
sql1.Fill(dt);
con.Open();
TimeSpan timespan1;
timespan1 = dateTimePicker3.Value - dateTimePicker2.Value;
int TotalDays = timespan1.Days+1;//total days that are taken from the datetimepicker
MessageBox.Show(TotalDays.ToString());//displaying the date for testing