?
Solved

Meeting alarm alert in vb.net app using date time from db table

Posted on 2005-05-05
11
Medium Priority
?
1,779 Views
Last Modified: 2012-06-21
Hi experts,
                my app created using vb.net & sql-server 2000, i've "Meetings" table in db, which includes "MeetingDate" & "MeetingTime" columns, my client want to get notify (alert) alarm for meetings, and this alert alarm will check Date & Time from  "Meetings" tables,
can someone guide me detailed example, or if there any Control (ActiveX) please let me know,
along alert i want to play a sound for specified time, and if my client mark any up coming meeting noticed (known), then it won't give alert for that specific meeting.

thanks in advance ,,,,
Nauman
0
Comment
Question by:nauman32
  • 5
  • 4
  • 2
11 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 13933638
Where do you want the alert to come from?

The system
SQL Server
Within your VB app - will the application be running in the background all the time or will it need to be started by some external process at a specific time?

0
 

Author Comment

by:nauman32
ID: 13934065
alarm should come from system, and only notify if application is running.
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 13934270
>> and only notify if application is running

I am still a bit confused. If the notification must happen only if the application is running can you not do something like this.

1. App Opens
2. App checks database for next meeting(s) it must alert client for
3. App calculates length of time from the current time to the alert time
4. App uses one of the efficient wait functions on a Timer or using a Waitable Timer to be notified when the specified amount of time has elapsed
5. If app receives notification before app terminates it displays the alert and resets the wait process to the next alert time.

I have done this in C++ quite effectively but not in vb.net. API's to look at are

CreateTimer with WaitForSingleObject

or

Waitable Timer functions (CreateWaitableTimer, OpenWatieableTimer, SetWaitableTimer etc)

You would need to run the scheduling part in a separate thread.

In .Net I think you need to look at the System.Threading.Timer class to do this


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:TDSnet
ID: 13934727
It sounds to me like you will need to create a Windows Service project, rather than a Windows Application project.  This could then be setup to start when Windows starts and run quietly in the background.  You could make it check the DB for meetings at intervals which you define (for example every minute or every 5 minutes or whatever) and then make it popup a message and play a sound when it finds a meeting is due.

Does this sound like what you require..?

Cheers,
Jack
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 13934884
Why create a new service when you can use the windows scheduler to run an app that does the check for you, besides nauman32  says in his second post that the alerts need to be created only when the vb app is running - therefore, while a service will do the trick it might not be within the scope of the requirements
0
 
LVL 6

Expert Comment

by:TDSnet
ID: 13935040
Personally I'd rather have the service which is just as easy to write, requires no API calls, and runs itself rather than requiring scheduling or manual execution.
0
 

Author Comment

by:nauman32
ID: 13953298
sorry experts , this is not what am looking for, still not find any adequate solution, i think we should forget here wheather notification come through (windows scheduler ) or my app, but this should work on times,
and same scenario meetingDate & meetingTime should be synchronised with database values, from Meetings table :S

i would like to have some real time solution,

0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 13957597
nauman32,

I think you need to be a bit more specific about what you are wanting then. The solutions presented pretty much cover all your options.

There are some questions that need to be answered in order for us to recommend a solution. Here are some options for you to consider.

Regarding notifications

Option 1

You want notifications to be generated at all times regardless of whether application is running or not.

Option 2

You want notifications to be generated only when user is using application (i.e. application is running)

How does your application work ?

Option 1

Your application runs all the time in the background. It regularly checks the database for meeting times and issues a notification when a match is made.

Option 2

Your application runs only when the user starts the application.

Which of these options you choose will determine the possible solutions to your problem.

0
 

Author Comment

by:nauman32
ID: 13967876
Thanks JulianH,

HERE ARE THE ANSWERS OF YOUR QUERIES:

Option 1

You want notifications to be generated at all times regardless of whether application is running or not.

Ans: no, notifications should generated when application is running

Option 2

You want notifications to be generated only when user is using application (i.e. application is running)

Ans: Yes indeed

How does your application work ?

Option 1

Your application runs all the time in the background. It regularly checks the database for meeting times and issues a notification when a match is made.

Ans: Application won't run all the time, neither it has background process which works all the time

Option 2

Your application runs only when the user starts the application.

Ans: Yes, its quiet simple app only started when user runs it

I TRIED IT LIKE THAT:

I tried it on my application's MainForm,while MainForm of my application is always visible, it has contents like this

0- OleDbDataAdapter

this adapter has select command which produce query to retrieve data from MeetingDate & MeetingsTime columns of Meeting table,

Me.OleDbSelectCommand1.CommandText = "SELECT serialNo, meetingDate, meetingTime FROM Meetings"
        Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1


1- Label1

2-Timer1

Timer1's Intervel is set to 1000

3- mydatetime (Variable) declared as date

on MainForm declaration area i declared mydatetime:

dim mydatetime as new date

then

on each tick of Timer1 this code  runs :

 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = mydatetime.Now
End Sub

So the Label1 shows the system date & time.

now on TextChanged event of Label1 i write this code so it runs a query against db table and check the MeetingDate & MeetingTime from Meetings table of db, and then synchronize it with system date and system time, and if both are same it gives some notification.

 Private Sub StatusBar1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles StatusBar1.TextChanged
        Dim mydatetime As DateTime = DateTime.Now
        mydatetime = New DateTime(mydatetime.Subtract(mydatetime.Date).Ticks)

        'If OleDbDataAdapter2.SelectCommand.Parameters("meetingDate").Value = Date.Today And OleDbDataAdapter2.SelectCommand.Parameters("meetingTime").Value = mydatetime Then
          MsgBox("You've a Meeting, Hurry up & Rush There", MsgBoxStyle.Critical, "Reminder")
        End If
       

THANKS AGAIN,
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 1000 total points
ID: 13968607
nauman32,

Rather use a TimerCallback function.

What you do is create a new timer with a callback function. When you initialise the timer set the callback function and the dueTime to the number of milliseconds from Now until the time of the first meeting. You can set the period to Timeout.Infinite or not depending on what best suits you.

Before creating the timer query the DB to find what time the next meeting is. Calculate the time difference between now and then and use that to initialise the timer.

When the call back is invoked display your message or whatever mechanism you want to use to notify the user. Immediately after this get the next meeting time and calculate the difference between now and the next meeting time.

USe the Timer.Change method to set the next due time and period.

And so on.

You will need to add additional code to check for cases where two or more meeting times are at the same time and make sure you issue notifications for all of them. I don't know how times are recorded in your database but if meetings at the same time can differ by milliseconds then your code would need to account for a range rather than a specific value i.e. Abs(Meeting1.Time - Meeting1.Time) < 500 then they are at the same time - or similar.

You will also need to make provision for the case where there are no records in the database so no next meeting time to set the timer for. In this case I would destory the timer and create it again only when there are records in the database.

That is the basic process - you will need to translate that into VB - if you are stuck post back and I will try and assist - right now I unfortunately don't have time to brush up on my VB to translate the solution ;)

Julian

0
 

Author Comment

by:nauman32
ID: 13984621
currently i am accomplishing another project when i will come back to this timer thing i will let u know what happened regards nauman
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Progress

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question