i use thsi code for timer , but it shows the messagebox 50 times.. i just need the mesage box to be showed once only

Dim conn As New OleDbConnection
Dim dap As OleDbDataReader
Dim cmdb As New OleDbCommand
conn.ConnectionString = Provider=Microsoft.JET.OLEDB.4.0;DATA SOURCE= c:\ApptDB.mdb"
conn.Open()
cmdb.Connection = conn
cmdb.CommandText = "select apdate from add1"
dap = cmdb.ExecuteReader()
Do While dap.Read
If dap.GetString(0) = Now.Date Then
MessageBox.Show("hi people ")
Timer1.Stop()

End If
Loop
conn.Close()

i use thsi code for timer , but it shows the messagebox 50 times.. i just need the mesage box to be showed once only

Dim conn As New OleDbConnection
Dim dap As OleDbDataReader
Dim cmdb As New OleDbCommand
conn.ConnectionString = Provider=Microsoft.JET.OLEDB.4.0;DATA SOURCE= c:\ApptDB.mdb"
conn.Open()
cmdb.Connection = conn
cmdb.CommandText = "select apdate from add1"
dap = cmdb.ExecuteReader()
Do While dap.Read
If dap.GetString(0) = Now.Date Then
MessageBox.Show("hi people ")
Timer1.Stop()

End If
Loop
conn.Close()

Hi
I have seen your problem and came to conclusion that the time interval is very low and before u click on first messge ("hi people")
the second messege coming again.
so you can do to things.
First increase the time interval of timer by 10000. and click on messege whenever messege came. or
Your can replace your codig by following
Dim conn As New OleDbConnection
Dim dap As OleDbDataReader
Dim cmdb As New OleDbCommand
conn.ConnectionString = Provider=Microsoft.JET.OLEDB.4.0;DATA SOURCE= c:\ApptDB.mdb"
conn.Open()
cmdb.Connection = conn
cmdb.CommandText = "select apdate from add1"
dap = cmdb.ExecuteReader()
Do While dap.Read
If dap.GetString(0) = Now.Date Then

Timer1.Stop()
MessageBox.Show("hi people ")

End If
Loop
conn.Close()

you have to replace just these two lines. I am sure it will work well.
bye


Hi
I have seen your problem and came to conclusion that the time interval is very low and before u click on first messge ("hi people")
the second messege coming again.
so you can do to things.
First increase the time interval of timer by 10000. and click on messege whenever messege came. or
Your can replace your codig by following
Dim conn As New OleDbConnection
Dim dap As OleDbDataReader
Dim cmdb As New OleDbCommand
conn.ConnectionString = Provider=Microsoft.JET.OLEDB.4.0;DATA SOURCE= c:\ApptDB.mdb"
conn.Open()
cmdb.Connection = conn
cmdb.CommandText = "select apdate from add1"
dap = cmdb.ExecuteReader()
Do While dap.Read
If dap.GetString(0) = Now.Date Then

Timer1.Stop()
MessageBox.Show("hi people ")

End If
Loop
conn.Close()

you have to replace just these two lines. I am sure it will work well.
bye

I just wanna thank you
it worked :)

This article has been dead for over six months. Start a new discussion instead.