AdvancedHMI Software

General Category => Open Discussion => Topic started by: Padex on February 10, 2017, 03:59:01 AM

Title: To filter data by date
Post by: Padex on February 10, 2017, 03:59:01 AM
Hi All,

Need your help... Im trying to filter my data based on SQLString but is not done well... catch all data... below is the code

Code: [Select]
Private Sub Show_Filter()
        Dim SQLString As String
        Dim Date1 As String
        Dim Date2 As String



        Date1 = DateFrom.Date & " 12:00:00 AM"
        Date2 = DateTo.Date & " 11:59:59 PM"


        TableName = "CAcpm"

        SQLString = "SELECT CAcpm.[No], CAcpm.Time, CAcpm.Date, CAcpm.[Pre CA], CAcpm.[Pos CA], CAcpm.[CA volume], CAcpm.Result, CAcpm.SKU, CAcpm.Remark, CAcpm.UserRec, CAcpm.[Vision Status], CAcpm.Station, CAcpm.UserIssue FROM " & TableName & " WHERE DateIn BETWEEN #" & Date1 & "# AND #" & Date2 & "#"


        ds.Clear()
        rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        rs.Open(SQLString, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

        da.Fill(ds, rs, TableName)

        DataGridView1.DataSource = ds.Tables(0)

    End Sub
Title: Re: To filter data by date
Post by: Mikefly95 on February 10, 2017, 08:14:00 AM
What Data base are you using?
Title: Re: To filter data by date
Post by: bachphi on February 11, 2017, 10:24:19 AM
I would set breakpoint at the date, step through and look at the  result of the dates, and sqlstring and see if its correct