Hello all!
I am having problem wih filewatch, I think. Basicly I have a trigger that
creates a file. Filewatch looks for a modified date on the file, than when
it see's it, it should pop up a message box. The problem it pop's up 3 or 4
message boxes. I just need it once.Here some code from app 1 that will
execute the store procedure.
Private Sub ON_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnON.Click
On()
End Sub
Here is the "On" store procedure.
REATE PROCEDURE [DBO].[On] AS
UPDATE OnOff
SET Switch = '1'
WHERE Switch = '0'
GO
Here is the trigger to create the file
CREATE TRIGGER [OutTxt] ON dbo.OnOff
FOR INSERT, UPDATE
AS
DECLARE @Switch varchar,
@OutCmd varchar(1000),
@OLEResult int,
@FileID int
--BEGIN
--EXEC master..xp_cmdshell 'del >E:\Switch.txt'
--End
BEGIN
SET @Bet = (SELECT MIN (DISTINCT Switch) FROM Inserted)
SET @OutCmd = 'echo' + ' ' + @Switch + ' >E:\Switch.txt'
END
BEGIN
EXEC master..xp_cmdshell @OutCmd
END
Now the File watch on app B.
Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal
e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
MessageBox.Show("All Switches Are On", "Switch")
The properties for filewatch are:
EnableRasingEvents True
Filter switch.txt
IncludeSubdirectiories False
NotifyFilter LastWrite
Sync Object MainFrm
Sorry so long, but this is a real head scratcher for me. I debug, and it
seems it keeps looping the file watch call.
TIA!!
Rudy