Sunday, March 25, 2012

ASP writing data to SQL Server 2000

I am having a problem with an ASP program that inserts data into a table on
SQL Server 2000.

No error msg is returned upon submission and the confirmation msg that
displays after the commit command is sent to the server displays, but when
we go to the DB, the data sent isn't there. This is an occassional
occurance and usually the data is there, just some times, it isn't. Other
forms function just fine, using the *exact* same file to perform the submit
function (all the forms "include" the same submit page). The only
difference we can find is a trigger on the table having problems which
executes upon update, capturing the information about who updated the record
when. From what we can see, this is the only programmatic difference. The
other thought tickling our minds was the possiblity of a simultaneous
submission, since all the users submit with the same db user name via the
form, if user 1's data gets written but not yet commited, user 2's data is
submitted, then the commit transaction is submitted by user 1 as the program
steps run in sequence, would the commit by user one cause eiither of the
records inserted but not commited to be lost? If so, why wouldn't that be causing problems on other forms ...Can you post some of the code that is being used? Particularly the trigger code... Also, use profiler to watch what is being sent to the SQL Server to determine if it is a SQL issue, or a ASP code issue.|||

Thank you Louis,

I will look into getting profiler turned on.

The trigger is as follows (specific variables replaced with generic names):

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE TRIGGER [trig_Table_doUpdateTimestamp] ON [dbo].[Table_1_0]
FOR UPDATE
AS
set nocount on
declare @.var1 datetime
declare @.var2 varchar(50)
declare @.var3 varchar(50)
declare @.var4 varchar(50)
declare @.var5 varchar(30)
set @.var1 = (select sourc_var1 from inserted)
set @.var2 = (select sourc_var2 from inserted)
set @.var3 = (select sourc_var3 from inserted)
set @.var4 = (select sourc_var4 from inserted)
set @.var5 = (select sourc_var5 from inserted)
update Table_1_0 set lastUpdateDT = getdate(), numberChanges = ( ( numberChanges + abs(numberChanges) ) /2 ) + 1 , lastupdateUser = SUSER_SNAME()
where sourc_var1 = @.var1 and sourc_var2 = @.var2 and sourc_var3 = @.var3 and sourc_var4 = @.var4 and sourc_var5 = @.var5
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

No comments:

Post a Comment