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

Recommended Answers

All 4 Replies

Try using timer1.enabled = false instead of timer1.stop

i tried , the same thing

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.