Report viewer not showing the exact date filtered by DateTime Picker

  • Thread starter Thread starter jepoyman
  • Start date Start date
J

jepoyman

Guest
Good day,

I am new in programming and just doing it for hobby putting at least 2 hours everyday to work on a project I have for my wife.

What I am trying to accomplish is trying to put on report viewer the data gathered on an attendance capture Table i have from the access data based.

I have a table named Attendance_Info and got some fields as follows primary key is AttID = autonumber, AttSerialNo = short text, Fullname = short text, Timestamp = short text, Remarks = short text and last is capturedImage = ole object.

On other form1 there it captures the attendance on it for AttSerialNo = txtSeriaNo, Fullname =txtFullname, Timestamp = DateTimePicker1 = long(in format at settings), Remarks = txtremarks and the last is captureImage = Picturebox1.

I was able to save data perfectly from the Form1 capturing attence. here comes the Form2 which i need to put it on report viewer.

On Form2 I have DateTimePicker1 and DateTimePicker2 = which I intend to filter the date of the captured attendance, I have also a button1 and the reportviewer1. On the solution explorer I right click then added an object dataset1 which I manually added the DataTable1 with columns AttSerialNo, Fullname, Timestamp and remarks. Then put a report1.rdlc and designed it with column AttSerialNo, Fullname, Timestamp and remarks.

On the Button1 click event lies the code

Dim RptDS As ReportDataSource

ReportViewer1.RefreshReport()

With ReportViewer1.LocalReport
.ReportPath = Application.StartupPath & "\Report\Report1.rdlc"
.DataSources.Clear()
End With

Dim ds As New DataSet1
adapter = New OleDbDataAdapter

connection = New OleDbConnection
With connection
If .State = ConnectionState.Closed Then
.ConnectionString = StrCon
.Open()
End If
End With

sql = "SELECT * FROM Attendance_Info WHERE Timestamp Between '" & (DateTimePicker1.Value.ToString("MMMM dd, yyyy")) &
"' AND '" & (DateTimePicker2.Value.ToString("MMMM dd, yyyy")) & "'"
adapter.SelectCommand = New OleDbCommand(sql, connection)
adapter.Fill(ds.Tables("DataTable1"))
connection.Close()

RptDS = New ReportDataSource("DataSet1", ds.Tables("DataTable1"))
ReportViewer1.LocalReport.DataSources.Add(RptDS)
ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
ReportViewer1.ZoomMode = ZoomMode.Percent
ReportViewer1.ZoomPercent = 70

Here comes the problem, it is not filtering the date between the DateTimePicker1 and DateTimePicker2. Instead it shows date and time which is not part of the filter date like for an example if you will choose month of May to June it will bring up February and March. It is not showing the accurate date and time from my specified filter dates.

I am sorry for the long description of my problem however to make more sense and easy for those people to understand where I am coming from.

Yours Truely,

Jepoyman

Thanks ,

Continue reading...
 
Back
Top