Link to home
Start Free TrialLog in
Avatar of nauman32
nauman32

asked on

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

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
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

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?

Avatar of nauman32
nauman32

ASKER

alarm should come from system, and only notify if application is running.
>> 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


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

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.

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,
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
currently i am accomplishing another project when i will come back to this timer thing i will let u know what happened regards nauman