Get data between two selected specific dates in vb.net
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..
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
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")
.CommandText = "SELECT * FROM driversearned WHERE DateTP >= @dt1 AND DateTP <= @dt2"
.Connection = conn
result = cmd2.ExecuteReader
.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
Edited 5 Years Ago by abc_123abc: display in [code]...[/code]
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"