PDA

Click to See Complete Forum and Search --> : generate event from sqlserver


Sep 18th, 2000, 02:52 PM
Hi,

Is there a way to have SQL Server generate an event
on an allready running VB-program?

Like when a table gets updated, i want the program to check it again, to see if it allready has to do something.

I know i should use a trigger, but I dont know what kind of code to use in the trigger, and also dont know how to have a vb-program start doing something triggered from the 'outside'...

Thanks,

Matthijs Vader

RIVES
Sep 18th, 2000, 02:55 PM
You could always check on whether the SQL statement you passed worked or not. There is a global variable in there called @@rowcount. This is the rowcount of the last SQL statement executed. You can use this variable for tests if the SQL statement you executed worked or not then return an int from a stored procedure etc. etc. etc.

Sep 18th, 2000, 03:17 PM
I knew that, sorry...

I'll explain more: In the database resides a 'job-list'
and there is a program running those jobs, one by one,
at the time given in the list. But another program can make changes in the list, and when it did, the first program should be notified.
Of course i can have the first program check every minute, but that is really a nice solution....

So i want to create some sort of event-handler in the first program wich retrieves the new job-list.And that event should be triggered by the sql-server when the job-list changes...

Thanks,

Matthijs Vader

RIVES
Sep 18th, 2000, 03:33 PM
I think what you need to look into is the alerts... see SQL-DMO in Building Server applications. Its hard to explain. From there, you can declare objects withevents in VB.

Good Luck.

Sep 18th, 2000, 03:42 PM
Where can i find this sql-demo, and building server applications?

Thanks,

Matthijs

RIVES
Sep 18th, 2000, 03:50 PM
In the SQL Server Book Online. I don't know if you can download it from Microsoft. It's usually shipped with the SQL server CD. Ask your admin to install it to your pc. Its about 11Mb of Help File. Its SQL-DMO (Distributed Management Object).

Why don't you just create a log table where in you insert transactions there. You can just query this table whenever there's a user intervention (like when saving or deleting). This would be alot easier...you could use triggers here just like you said.

Hmmmn. Again, good luck.

Sep 18th, 2000, 04:00 PM
I found the SQL-Demo thing,

it looks like i'll be working on it for some time....


Maybe I dont understand your solution, but i think that
with your solution, the problem stays: the job-processor program has to know that something has changed. It is running on a complete different system/computer(the same as the sql-server) as the program that alters the jobs, and thus has to be notified of the change,
so it can see if it has to alter his timers.


thanks for all your help sofar!

Matthijs.