error in retrieving records between dates
Hi,
i have written code to retrieve records from database when date is between some 2 dates and username should be same, the error is when i want to display records between 4th feb to 6th feb then only 5th & 6th feb records are only coming, the code is,
Imports System.Data.OleDb
Public Class Search2
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Private Sub Search2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dg1.Visible = "False"
End Sub
Private Sub bt_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_Search.Click
Try
Dim fdt As Date = dtp_Fromdate.Text
Dim tdt As Date = dtp_Todate.Text
Dim us As String = txtbx_Username.Text
myConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='h:\info2.mdb'")
Dim strQry As String = "select [ID],[Dt],[Res],[Construction Package],[Region],[Trade],[Location],[Network Name],[Task],[Progress],[Duration],[Assumptions] from Record where Dt between '" & fdt & "' and '" & tdt & "' and Res = '" & us & "'"
myConnection.Open()
Dim ds As New DataSet
Dim da As New OleDbDataAdapter(strQry, myConnection)
da.Fill(ds, "Record")
If (ds.Tables(0).Rows.Count > 0) Then
dg1.DataSource = ds
dg1.DataMember = "Record"
dg1.Visible = "true"
Else
dg1.Visible = "false"
Label1.Text = "No Records"
End If
myConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
End Class
Thanks,
Swetha.