PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
DateTimePicker not showing the intended records-VBForums
Results 1 to 4 of 4

Thread: DateTimePicker not showing the intended records

  1. #1

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    192

    DateTimePicker not showing the intended records

    Hello!

    I'm trying to display the records between two dates in a DGV, I'm using a DateTimePicker2 and a DateTimePicker3
    I select January 10th on DateTimePicker2 and January 13th on DateTimePicker3 and I'm getting almost all the records but the ones from January 10th. I have no idea why it is not showing those records

    This is my query:
    vb.net Code:
    1. Dim command As New SQLiteCommand("SELECT * FROM Employees_table WHERE Nombre = '" & ComboBox1.Text & "' And (Fecha BETWEEN @d1 AND @d2)", Connection1)
    2. command.Parameters.Add("@d1", SqlDbType.Date).Value = DateTimePicker2.Value
    3. command.Parameters.Add("@d2", SqlDbType.Date).Value = DateTimePicker3.Value
    4. Dim adapter As New SQLiteDataAdapter(command)
    5. adapter.Fill(table)

    This is my DGV:
    Name:  01.jpg
Views: 35
Size:  24.5 KB

    This my Table:
    Name:  02.jpg
Views: 32
Size:  11.7 KB

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,749

    Re: DateTimePicker not showing the intended records

    Code:
    command.Parameters.Add("@d1", SqlDbType.Date).Value = DateTimePicker2.Value
    I believe that that is the wrong data type. See documentation here. SQLite has no native support for dates and you need a bit of jiggery-pokery to work with date values. If you haven't already, you ought to read up on that subject.

  3. #3

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    192

    Re: DateTimePicker not showing the intended records

    In my case, the following code solved my issue.

    vb.net Code:
    1. command.Parameters.Add("@d1", SqlDbType.Date).Value = DateTimePicker2.Value.ToShortDateString

    thanks for your help!

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,749

    Re: DateTimePicker not showing the intended records

    Do you have Option Strict Off? I suspect that turning it On would generate a compilation error on that line. Even if it works, you should still do it properly because there may be other times where similarly using the wrong type doesn't work.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width