how can i get the value accumulated from the date i select from datetimepicker1 to datetimepicker2 in vb.net and mysql? the value here refers to the daily sales and i need to find the total sales between the range dates that i choose..
please help me..as im beginner and my knowledge is limited..
thanks in advance..

Edited 5 Years Ago by abc_123abc: typo error

You didnt say exactly where from, so I will assume from database.
You can write an sql query that will look like:

Dim sqlQuery As String = "SELECT * FROM MyTable WHERE DateColumn >= @param1 AND DateColumn <= @param2"
'by using sqlcommand you then define parameters:
cmd.Parameters.Add("@param1", SqlDbType.DateTime).Value = datetimepicker1.Value
cmd.Parameters.Add("@param2", SqlDbType.DateTime).Value = datetimepicker2.Value

You can also use the syntax

Dim sqlQuery As String = "SELECT * FROM MyTable WHERE DateColumn BETWEEN @param1 AND  @param2"

thank you very much to both mitja and jim!!
but there's a problem here , when i select the date retrieving from database from start date to end date, there's an error displaying the result to my listview, where for eg, when i choose dates from 01/10/2011 to 31/10/2011, the result display 3 rows result where i only have 2 results in my database.. is there any problem with my code??

Dim result As MySqlDataReader
        result = Nothing

        Dim cmd2 As New MySqlCommand
        conn = New MySqlConnection("Server = " + _host + ";User ID = " + _user + ";Password = " + _pass + ";database = transportation")

            With cmd2
                .CommandText = "SELECT * FROM driversearned WHERE DateTP >= @dt1 AND DateTP <= @dt2"
                .Connection = conn
                .Parameters.AddWithValue("@dt1", DateTimePicker1.Text.Trim)
                .Parameters.AddWithValue("@dt2", DateTimePicker2.Text.Trim)
            End With
            result = cmd2.ExecuteReader
            With DriversEarnedListView
                .FullRowSelect = True
                .View = View.Details
                .GridLines = True
                .Sorting = Windows.Forms.SortOrder.Ascending
                .Columns.Add("DriversName", 140, HorizontalAlignment.Left)
                .Columns.Add("Charges", 140, HorizontalAlignment.Left)

                Do While result.Read

                    drvname = result.GetString(result.GetOrdinal("DriversName"))
                    comm = result.GetString(result.GetOrdinal("Charges"))

                    NewItem = New ListViewItem(drvname)


                    count = count + 1

            End With

Edited 5 Years Ago by abc_123abc: display in [code]...[/code]

it's ok now..i think i was refering to wrong table...thanks for the help ya!!! ^^

This question has already been answered. Start a new discussion instead.