Results 1 to 2 of 2

Thread: datetime picker control

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    11

    datetime picker control

    hi all! i have here a code

    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)
                Dim sql2 = "Select * from finaltickettable where work_group = '" & CheckBox1.Text & "' and date_handled = '" & DateTimePicker1.Value & "'"
                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

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: datetime picker control

    Why are you executing your command before you assign it to your data adapter? And why are you executing it using ExecuteNonQuery when you're using a SELECT? And why are you declaring the select statement in your sql2 string when you're not using it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width