I am very new to the 'trigger' concept and need to set an update trigger on table table alerts to update the alertcount field in table alertcounter:
here is what I have s far:
/****** Object: Trigger [dbo].[trg_increment Alert] Script Date: 10/21/2008 11:39:38 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER trigger [dbo].[trg_increment alert] on [dbo].[TblAlerts] After Update
update tblalertcounter set alertcount = alertcount+1
I get no errors and the alertcount field does not increment by 1.
I am not sure supplying the data that appears in tblalerts will help. I think I am explaining my intentions incorrectly. Anyway, TBLAlerts has the following fields:
When data is inserted into TBLalerts, I basically want some way of creating an alert in my ASP2 webpage. I am using VS 2005 ASP2/VB. I have a label on my webform which should display the number of alerts.
When data is inserted into TblAlerts I thought I could track this by using a trigger. for example:
Data is inserted into tblalerts
trigger is initiated and updates alertcount in tblalertcounter by 1
I then plan to open a connection (from my web app using VB code) to tblalertcounter and store the contents of alertcount in LblAlert.text.
So, in theory there should only ever be one record in tblalertcounter and the value in alertcount will simple increment by 1 each time data is inserted in TblAlerts.
There probably is abetter way of doing this, I am just inexperienced and I beginning to confuse myself! LOL