i search a lot of reference in web, but still im not satisfied to solve this problem, i used datetimepicker in vb.net to retrieve from database. i am using BETWEEN statement to search the specific date and its data.

here is my code to search the data with specific date, i have to datepicker:

Dim sqlquery As String = "SELECT complaint.*,solution.* FROM complaint LEFT JOIN solution ON complaint.tran_no=solution.tran_no WHERE complaint.status='finished' AND complaint.sys_name LIKE '%" & cbosyshis.Text & "%' AND complaint.mod_name LIKE '%" & txtmodhis.Text & "%' AND complaint.dte BETWEEEN '" & date1.text & "' AND '" & date2.text & "'"
        Dim sqladapter As New MySqlDataAdapter
        Dim sqlcmd As New MySqlCommand
        Dim table As New DataTable
        Dim i As Integer



        With sqlcmd
            .CommandText = sqlquery
            .Connection = connectionsrvr
        End With

        With sqladapter
            .SelectCommand = sqlcmd
            .Fill(table)
        End With



        For i = 0 To table.Rows.Count - 1
            With lvhistory
                .Items.Add(table.Rows(i)("date"))
                With .Items(.Items.Count - 1).SubItems
                    '.Add(table.Rows(i)("date"))
                    .Add(table.Rows(i)("tran_no"))
                    .Add(table.Rows(i)("comp_type"))
                    .Add(table.Rows(i)("status"))
                    .Add(table.Rows(i)("sys_name"))
                    .Add(table.Rows(i)("mod_name"))
                    .Add(table.Rows(i)("err_desc"))
                    .Add(table.Rows(i)("trigg"))
                    .Add(table.Rows(i)("comp_fname") & " " & table.Rows(i)("comp_lname"))
                    .Add(table.Rows(i)("comp_pos"))
                    .Add(table.Rows(i)("list_sol"))
                    .Add(table.Rows(i)("recby"))
                    .Add(table.Rows(i)("sol_recby"))
                    .Add(table.Rows(i)("sol_del"))



                End With

            End With
        Next

Edited 3 Years Ago by sheerwoodjohn.caday

This article has been dead for over six months. Start a new discussion instead.