0

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()

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by yaya_star
0

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


0

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 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.