Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

VS 2010 [RESOLVED] Date Range

$
0
0
Hi, I am using VB 2010 Express.
I am having a problem with date range which I am not able to fix. Please Help!

Problem details : When I try to search from start date 15/03/2013 [DD/MM/YYYY] to 20/03/2013 (for example), I only get result from 15/03/2013 to 19/03/2013 with my code. So if i want to get result till end date 20/03/2013, I have to enter end date as 21/03/2013.

My Code :

Code:

      Try
                con.Open()
                ID = 0
                Dim dt As New DataTable("dExp")
                Dim rs As OleDb.OleDbDataAdapter
                rs = New OleDb.OleDbDataAdapter("SELECT * FROM dExp WHERE (dDate >= @startDate) AND (dDate <= @endDate)", con)
                Dim param1, param2 As OleDbParameter
                param1 = New OleDbParameter("@startDate", StrDt.Value.Date)
                param2 = New OleDbParameter("@endDate", EndDt.Value.Date)
                rs.SelectCommand.Parameters.AddRange(New OleDbParameter() {param1, param2})
                rs.Fill(dt)
                List1.Items.Clear()

                For indx = 0 To dt.Rows.Count - 1
                    Dim lst As New ListViewItem

                    lst.Text = dt.Rows(indx).Item("ID")
                    lst.SubItems.Add(dt.Rows(indx).Item("dTextWhatever1"))
                    lst.SubItems.Add(dt.Rows(indx).Item("dTextWhatever2"))
                    lst.SubItems.Add(dt.Rows(indx).Item("dTextWhatever3"))
                    lst.SubItems.Add(dt.Rows(indx).Item("dTextWhatever4"))

                    List1.Items.Add(lst)

                    Dim dAmt As Decimal = List1.Items.Cast(Of ListViewItem).Sum(Function(lvi) CDec(lvi.SubItems(1).Text))
                    WResult.Text = dAmt


                Next
                If List1.Items.Count = 0 Then
                    WResult.Text = "No Results Found"
                End If
                con.Close()
                rs.Dispose()

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try


Viewing all articles
Browse latest Browse all 27201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>