hi all! i have here a code

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        mycommand = New MySqlCommand
        Dim daMyName As New MySqlDataAdapter
        Dim dsMyName As New DataSet
        Try
            connection()
            mycon.Open()
            With mycommand
                .Connection = mycon
                .CommandText = "Select * from finaltickettable where work_group = '" & CheckBox1.Text & "' and date_handled = '" & DateTimePicker1.Value & "'"
                .ExecuteNonQuery()
            End With
            daMyName.SelectCommand = mycommand
            daMyName.Fill(dsMyName)
            [B]Dim sql2 = "Select * from finaltickettable where work_group = '" & CheckBox1.Text & "' and date_handled = '" & DateTimePicker1.Value & "'"[/B]
            If CheckBox1.Checked = True Then
                With ListView1
                    .Clear()
                    .View = View.Details
                    .FullRowSelect = True
                    .GridLines = True
                    .Columns.Add("Fault Number", 150)
                    .Columns.Add("Reported Date", 150)
                    .Columns.Add("Fault Description", 150)
                    .Columns.Add("Work Group", 150)
                    .Columns.Add("SubTeam", 150)
                    .Columns.Add("Service Type", 150)
                    .Columns.Add("PL Number", 150)
                    .Columns.Add("Fault Type", 150)
                    .Columns.Add("User", 150)
                    .Columns.Add("Date/Time Handled", 150)
                    FillListView(ListView1, GetData(sql2))
                End With
                Label3.Text = ("Team A Exported!")
            ElseIf CheckBox1.Checked = False Then
                Label3.Text = ""
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

the bold part is my problem. its about date time picker. there is no error but whenever i choose a date that was handled on the specific day, there is no data displayed in my excel file with the selected date. but in my database, there was a ticket handled on the day that i picked kindly help me

Recommended Answers

All 4 Replies

I would check the format of the datetimepicker value against the format in the column for the database. The SQL statement is probably not finding a match on that criteria.
You are also using checkBox1.Text in the SQL statement. Are you sure you don't want CheckBox1.Checked?

hi hericles!
the format is same. its date. the reason why i used checkbox1.text is because the text in my checkbox1 is also the name in my database.

I figured it is date but there a lot of different formats that get covered by that. Your SQL database is most likely storing the date with a time element as part of it unless you have specifically formatted the data not too.
If you can open up the SQL server control panel or command prompt and type in the SQL statement you are using and see if it works there, or select the date column out to see exactly what the values look like.
I got frustrated once because I was trying to find the date as dd/mm/yy when MySql had inserted it as yy/mm/dd:hh:mm:ss (even though the hours, minutes and seconds were all zeros).

i placed this code on my form load

DateTimePicker1.Format = DateTimePickerFormat.Custom
        DateTimePicker1.CustomFormat = "yyyy-MM-dd"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.