473,383 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

select data from data grid view between two dates

I'm trying to select data between tow dates(values given by date time pickers) I try more. but can't go forward. here is my code :
Expand|Select|Wrap|Line Numbers
  1. Try
  2.             If (con.State = ConnectionState.Closed) Then
  3.                 con.Open()
  4.             End If
  5.             cmd = New MySqlCommand("SELECT * FROM mcs.daily_income where date_received between @d1 and @d2", con)
  6.             cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "JoiningDate").Value = dtpstart.Value.Date
  7.             cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "JoiningDate").Value = dtpend.Value.Date
  8.             da = New MySqlDataAdapter(cmd)
  9.             ds = New DataSet()
  10.             da.Fill(ds, "Staff")
  11.             dgvreciept.DataSource = ds.Tables("Staff").DefaultView
  12.             ds.Clear()
  13.             da.Dispose()
  14.             con.Close()
  15.         Catch ex As Exception
  16.             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  17.         End Try
  18.         Dim ii As Integer
  19.         Dim total As Decimal
  20.         For ii = 0 To dgvreciept.Rows.Count - 1
  21.             total = total + Val(dgvreciept.Item("Amount", ii).Value.ToString) ' or you can use Cint
  22.         Next
  23.         lbltdtotal.Text = total
  24.  
my data grid view item's name : dgvreciept
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 :)
Jan 23 '16 #1
0 1403

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: weiwei | last post by:
Hi; I am having trouble to get variable from grid view. here is my scenario. I want to delete a row in database from web page, in additon, I also want to delete that user's directory in c:drive. ...
0
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
0
by: nanaalwi | last post by:
hi there, im doing a project right now to download a data from EEPROM of a camcorder. i used a 'data grid view' to display all the data downloaded from the camcorder. however, i have to save the...
1
by: mehdi1727 | last post by:
How Print Data Grid View in C#.Net??????????
1
by: vibhashin | last post by:
I hve extracted a coloumn in combo box from database. I want that when i select a particular value from the combo box it should display the related details of the selected value in the combo box in...
1
by: mcupito | last post by:
I am trying to populate a data grid view based off of two text boxes, Start date and End date. I am not sure how to work with DataGridViews or DataSets. So if textbox1.text = x/x/2013 and...
0
by: jaseem0712 | last post by:
I have a data grid view like this: http://bytes.com/attachment.php?attachmentid=7458&stc=1&d=1390739933 i am loading data grid view like this: Dim cd As SqlCommandBuilder = New...
4
Ajay Bhalala
by: Ajay Bhalala | last post by:
I am Using the MS Access database as backend tool. I have the question which I want to do is as follows... Q : Create a database "Student" which consist of following fields : • id • name • c •...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.