I going to build a program that notify me daily according to time which i have save it in the database table. The idea is when the current time in the system is equal to the time stored in the database, the system will prompt the notification such as msgbox.
My table are
Notify
Field Type Example Data
ID Text 1
Name Text Zul
Time1 Text 4:00 AM
Time2 Text 12:00 PM
Time3 Text 8:00 PM
Code to run current time and to validate the current data exist in the table
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
timeToday.Text = System.DateTime.Now.ToShortTimeString
Dim cmd1 As New OleDbCommand("Select * from Notify where '" & timeToday.Text & "' = Time1 OR Time2 OR Time3", OleDbConnection)
Try
OleDbConnection.Open()
OleDbDataReader = cmd1.ExecuteReader()
MsgBox(OleDbDataReader("Name"))
Catch ex As OleDbException
' Create and error column header
Dim ErrorHeader As New ColumnHeader()
ErrorHeader.Text = "oledb Error"
'ListPR.Columns.Add(ErrorHeader)
Finally
OleDbConnection.Close()
End Try
End Sub
Result:
No data exists for the row/column on the
MsgBox(OleDbDataReader("Name"))
I also try to make an simple statement in the timer code by such as below but it cant work. It like that the 10:30 PM is not in time format
If
timeToday
.text = "10:30 PM" true thenmsgbox("Hi there")
end if
Can anyone help me with this problem?
Hirendra SisodiyaPosted Mar 20, 2010, 2:13 AM
Dim cmd1 As New OleDbCommand("Select * from Notify where (Time1='" & timeToday.Text & "') OR (Time2= '" & timeToday.Text & "') OR (Time3='" & timeToday.Text & "')", OleDbConnection)
thanks
ZULFAHMI AIDIPosted Mar 23, 2010, 11:44 PM
Hirendra SisodiyaPosted Mar 22, 2010, 4:48 AM
can you send me your both Database table, i will check on my side that what is happening wrong.....
thanks
ZULFAHMI AIDIPosted Mar 21, 2010, 6:48 AM