Question

I have a cross reference table RolePrivilege that has FK to Role and Privilege tables....basically Role can have many Privileges.

Hotfix located at Microsoft hotfix

has already been applied.

Here is my code:

Public Sub InsertRolePrivilege(ByVal inrole As Role, ByVal inprivilege As Privilege)
        Dim r As Role = (From ro In DataConnect.dcGSFCommon.Roles Where ro.RoleId = inrole.RoleId).First

        Dim rolep As New RolePrivilege
        rolep.PrivilegeId = inprivilege.PrivilegeId
        rolep.CreatedBy = System.Threading.Thread.CurrentPrincipal.Identity.Name
        rolep.DateCreated = System.DateTime.Now()
        rolep.RolePrivilegeId = System.Guid.NewGuid()

        r.RolePrivileges.Add(rolep)

        DataConnect.dcGSFCommon.SubmitChanges()

    End Sub

On execution of the last line, I get the following error: The target table 'dbo.RolePrivilege' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.

The app is a windows app, with 2008 SQL server with updated patch, version 9.0.4035

Any help would be appreciated.

Was it helpful?

Solution

Presumably (since you didn't say)

  1. There's a trigger on the table.
  2. You can't remove the trigger.

If you examine the generated sql (set DataContext.Log to Console.Out ), you'll see an output clause. The purpose of this clause is to Autosync properties on your instances with the database generated values.

What you need to do is set the AutoSync property on each column to AutoSync.Never. You can do this through the linq to sql designer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top