I'm using an MS Access Database 2013 as frontend to connect to a MS SQL Server 2017.
Dim rst As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim conn As New ADODB.Connection
With conn
.CursorLocation = adUseClient
.ConnectionString = strSQLOLEDB
.Open
End With
cmd.CommandType = adCmdStoredProc
cmd.CommandText = strStoredProcedure
cmd.ActiveConnection = conn
cmd.CommandTimeout = 120
cmd.Parameters.Append cmd.CreateParameter(strID_Bez, adInteger, adParamInput, , intID)
rst.Open cmd, , adOpenKeyset, adLockOptimistic
This worked fine for me and I also could use an Trigger to set the changing date/time as a manual timestamp:
CREATE TRIGGER [dbo].[tr_Emailadress_After_Update]
ON [dbo].[Emailadress] AFTER Update, Insert
AS
BEGIN
SET NOCOUNT ON;
UPDATE Emailadress
SET Email_TS = sysdatetime()
WHERE Email_ID IN ( SELECT Email_ID
FROM inserted
)
Now I'm trying to use the OLTP In-Memory-Technic of MS SQL Server (that's also the reason for the manual timestamp as OLTP does not offer a timestamp) and the Trigger does not work any more.
I searched a lot for a solution and found out, that this will work for me:
CREATE TRIGGER [dbo].[tr_Emailadress_After_Update] ON [dbo].[Emailadress] WITH NATIVE_COMPILATION, SCHEMABINDING AFTER Update , INSERT
AS
BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'german')
DECLARE @intEmail_ID int
SELECT @intEmail_ID = I.Email_ID
FROM Inserted I
UPDATE dbo.Emailadress
SET Email_TS = sysdatetime()
WHERE Email_ID = @intEmail_ID
END
GO
But now I'm having another problem. I can change data in my Access form, but because of the Trigger the change will not be committed. Without Trigger it works fine... but with Trigger not. If I'm sending an Update directly at SSMS to the table trigger & change will work fine. If I delete the trigger Access will work fine.
I tried to change the TRANSACTION ISOLATION LEVEL
but did not found a solution for the problem.