Problem with trigger on mp_Users table

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
4/17/2012 7:25:43 AM
Gravatar
Total Posts 3

Problem with trigger on mp_Users table

Installation details:

mojoPortal Version 2.3.5.4 MSSQL

Microsoft Windows NT 6.1.7601 Service Pack 1

ASP.NET v2.0.50727 in 'Partial Trust'

Time zone: W. Europe Daylight Time

I all,

I've created a trigger on mp_Users table that insert a record in another table named myTable when a new user is inserted in mp_Users table.
The trigger works, but after inserting a new user (from admin panel in my website), the Member List is completely corrupted (duplicated users, admin user deleted...)

I create the same trigger in the last mojoportal version on my local pc, but the problem still there.

The trigger script is:
CREATE TRIGGER [dbo].[myTrigger] ON [dbo].[mp_Users]
FOR INSERT
AS
DECLARE @myID INT
DECLARE @myName NVARCHAR(50)
DECLARE @myMail NVARCHAR(50)
SELECT @myID =(SELECT UserID FROM INSERTED)
SELECT @myName =(SELECT Name FROM INSERTED)
SELECT @myMail =(SELECT Email FROM INSERTED)
INSERT INTO myTable (UserID, UserName, UserMail) VALUES (@myID, @myName, @myMail)

Please help.

5/24/2012 8:31:07 AM
Gravatar
Total Posts 3

Re: Problem with trigger on mp_Users table

no one can help me on this issue?

5/25/2012 3:56:28 AM
Gravatar
Total Posts 3

Re: Problem with trigger on mp_Users table

Solved!
Changed from "FOR INSERT" to "AFTER INSERT" and put inside "BEGIN...END" the trigger actions.

This is the new trigger script:

ALTER TRIGGER [dbo].myTrigger ON [dbo].mp_Users

AFTER INSERT
AS
BEGIN
  DECLARE @myID INT
  DECLARE @myName NVARCHAR(50)
  DECLARE @myMail NVARCHAR(50)
  SELECT @myID =(SELECT UserID FROM INSERTED)
  SELECT @myName =(SELECT Name FROM INSERTED)
  SELECT @myMail =(SELECT Email FROM INSERTED)
  INSERT INTO [dbo].myTable (UserID, UserName, UserMail) VALUES (@myID, @myName, @myMail)
END

You must sign in to post in the forums. This thread is closed to new posts.