datetime picker control

sigridish

Member
Joined
Nov 10, 2011
Messages
22
Programming Experience
Beginner
hi all! i have here a code

VB.NET:
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
 
Do not use string concatenation to insert values into SQL code. Always use parameters. This and various other problems will just go away. Follow the Blog link in my signature and check out my post on ADO.NET Parameters to learn why and how.
 
Back
Top