0

How can I filter records from the clock set at right angles
In data if I add a column is minute
Time from start plus column-minute
any help?
thanks a lot

Imports System.Data.OleDb
Public Class Form1
Dim con As OleDbConnection
Dim dt As DataTable
Dim da As OleDbDataAdapter
Dim str As String = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\Nwind.mdb;"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim conn As OleDbConnection = New OleDbConnection(str)
conn.Open()
Dim dt As DataTable = New DataTable()
For Each _row As DataRow In dt.Rows
Dim _now As DateTime = Now
_now = _now.AddMinutes(_row("Duration"))
Dim sQry1 As String = "select * from tblTimeLoad where Start='" & _now.ToString("yyyy-MM-dd hh:mm:ss tt") & "'"
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sQry1, conn)
da.Fill(dt)
DataGridView1.DataSource = dt
Next
conn.Close()
End Sub
End Class

https://www.mediafire.com/?mk4v9cvcm47u29n

2
Contributors
1
Reply
13
Views
2 Years
Discussion Span
Last Post by Shark_1
0

How can I filter records from the clock set at right angles

What do you mean by right angles?
Did you mean DatagridView will load fresh data after every 15minutes or every single minute? Which one?

I have done here some modification in your codes, which will load a refresh list of data to the DataGridView in every munites.

Imports System.Data.OleDb
Public Class Form1

Dim str As String = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\Nwind.mdb;"
Dim con As New OleDbConnection(str)
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim _now As DateTime = Now()
Dim nwSec As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Initialize the Timer Object.
'Set the interval to 1000 milisecond=1Second
'i.e. Timer is ticked after every second.
Timer1.Enabled = True
Timer1.Interval=1000
nwSec = 1
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

'Adding Every Second
nwSec += 1

'Check this is a Minute or not

If nwSec<60 Then Exit Sub

'When this is a munite do the followings

'Clear data from DataGridView
DataGridView1.Rows.Clear()
DataGridVIew1.Columns.Clear()

'increase the time by a minute
_now = _now.AddMinutes(1)

'Check & Open the connection
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()


'Build the Querry.
Dim sQry1 As String = "select * from tblTimeLoad where Start='" & _now.ToString("yyyy-MM-dd hh:mm:ss tt") & "'"
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sQry1, conn)
da.Fill(dt)

'Show Data to the DataGridView Object
DataGridView1.DataSource = dt

'Dispose all Data Objects
dt.Dispose()
da.Dispose()
conn.Close()

'Set Second Value to 1
nwSec=1

End Sub

End Class

If you want to tick the timer after a minute, set Timer Interval Property to 60000 miliseconds, then there is no need to check the nwSec variable is 60 or not. I suppose it could help you.

Edited by Shark_1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.