Expand|Select|Wrap|Line Numbers
- Try
- If (con.State = ConnectionState.Closed) Then
- con.Open()
- End If
- cmd = New MySqlCommand("SELECT * FROM mcs.daily_income where date_received between @d1 and @d2", con)
- cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "JoiningDate").Value = dtpstart.Value.Date
- cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "JoiningDate").Value = dtpend.Value.Date
- da = New MySqlDataAdapter(cmd)
- ds = New DataSet()
- da.Fill(ds, "Staff")
- dgvreciept.DataSource = ds.Tables("Staff").DefaultView
- ds.Clear()
- da.Dispose()
- con.Close()
- Catch ex As Exception
- MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Dim ii As Integer
- Dim total As Decimal
- For ii = 0 To dgvreciept.Rows.Count - 1
- total = total + Val(dgvreciept.Item("Amount", ii).Value.ToString) ' or you can use Cint
- Next
- lbltdtotal.Text = total
date time pickers names :
1- dtpstart
2- dtpend
After selecting data I want to compute sum of amount field.
when I run this that give me error:
"Invalid cast from 'date time' to 'single' "
Please be kind to help my prob :)