Try
d1 = dtpfrom.Value.Date()
d2 = dtpto.Value.Date()
SQL = "SELECT Student_ID FROM Ate_entry"
execComDB(SQL)
reader = cmd.ExecuteReader()
If reader.Read() Then
reader.Close()
Try
SQL = "SELECT Student_regno,Student_Std,Student_branch,Attendance_Date,Attendance_Status,Entry_User,Entry_Date,Entry_Time FROM Ate_entry where Student_ID='" & txtstuid.Text & "' and (Attendance_Date Between '" & d1 & "' AND '" & d2 & "')"
'cmd.Parameters.AddWithValue("@from", dtpfrom.Text) ("SELECT * from stockitems where stdate Between #" & _ dtDate1.ToString("MM/dd/yyyy") & "# And #" & _dtDate2.ToString("MM/dd/yyyy") & "#",con)
'cmd.Parameters.AddWithValue("@to", dtpto.Text)
execComDB(SQL)..
..
I am using this code but it not including the year....only taking month and date....
Rajavel GPosted Jan 11, 2017, 6:02 AM
Form code:
Public Class Student_attendance_Report
Dim d1 As Date
Dim d2 As Date
Private Sub Student_attendance_Report_Load(sender As Object, e As EventArgs) Handles MyBase.Load
dtpfrom.CustomFormat = "MM/dd/yyyy"
dtpto.CustomFormat = "MM/dd/yyyy"
dtpto.MinDate = dtpfrom.Value.Date.AddDays(1)
End Sub
Private Sub btnsearch_Click(sender As Object, e As EventArgs) Handles btnattendance.Click
Try
d1 = dtpfrom.Value.Date()
d2 = dtpto.Value.Date()
SQL = "SELECT Student_ID FROM Ate_entry"
execComDB(SQL)
reader = cmd.ExecuteReader()
If reader.Read() Then
reader.Close()
Try
cn.open()
cmd.commandtext = "SELECT Student_regno,Student_Std,Student_branch,Attendance_Date,Attendance_Status,Entry_User,Entry_Date,Entry_Time FROM Ate_entry where Student_ID='" & txtstuid.Text & "' and (Attendance_Date Between '" & d1 & "' AND '" & d2 & "')"
'cmd.Parameters.AddWithValue("@from", dtpfrom.Text) ("SELECT * from stockitems where stdate Between #" & _ dtDate1.ToString("MM/dd/yyyy") & "# And #" & _dtDate2.ToString("MM/dd/yyyy") & "#",con)
'cmd.Parameters.AddWithValue("@to", dtpto.Text)
cmd.executenonquery()
reader = cmd.ExecuteReader()
If reader.Read() Then
reader.Close()
Dim adapter As New SqlDataAdapter
adapter.SelectCommand = cmd
Dim dt As New DataTable
adapter.Fill(dt)
dgvattendancereport.DataSource = dt
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
reader.Close()
' attendancepercentage()
Else
MessageBox.Show("Not Exist")
reader.Close()
End If
reader.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Nitin SontakkePosted Jan 11, 2017, 5:51 AM