Error when i tried to remove the 'Manage Forum' button

Topics: Help
Jul 7, 2007 at 12:52 PM
Hello.

I made the mistake of trying to remove the "Manage Forum" button and "Forums\Manage.aspx" from being accessed by the Administrator role. I only want the "UserEdits" role to see that button. When i go to Forums, select a forum, then select a thread(topic) under Subject, i get the following error:

Server Error in '/GirgentiWebSite' Application.
--------------------------------------------------------------------------------

The INSERT statement conflicted with the FOREIGN KEY constraint "FKMembersForumsMemberInfo". The conflict occurred in database "C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\MY DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\GIRGENTIWEBSITE\APP_DATA\CLUBDB.MDF", table "dbo.MemberInfo", column 'memberid'.
The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FKMembersForumsMemberInfo". The conflict occurred in database "C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\MY DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\GIRGENTIWEBSITE\APP_DATA\CLUBDB.MDF", table "dbo.MemberInfo", column 'memberid'.
The statement has been terminated.

Source Error:

Line 55: cmd.Parameters.AddWithValue("@memberid", _memberid)
Line 56: conn.Open()
Line 57: Dim reader As SqlDataReader = cmd.ExecuteReader()
Line 58: If reader.HasRows() And reader.Read() Then
Line 59: _displayname = reader.GetString(0)

Source File: C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\GirgentiWebSite\App_Code\ForumUser.vb Line: 57

I added the following code:

Forum/Topics.aspx:

If Not IsPostBack Then
' Modified 07/06/2007 by Lakeside Office Systems, Inc.
' Panel1.Visible = User.IsInRole("Administrators")
Panel1.Visible = User.IsInRole("UserEdits")
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Panel2.Visible = User.Identity.IsAuthenticated
SqlDataSource2.CancelSelectOnNullParameter = True
If User.Identity.IsAuthenticated Then
SqlDataSource2.SelectParameters("memberid").DefaultValue = Membership.GetUser.ProviderUserKey.ToString()
End If
End If

Web.config:

<location path="forum/manage.aspx">
<system.web>
<authorization>
<!--
Following line Modified 07/06/2007 by Lakeside Office Systems, Inc.
<allow roles="Administrators"/>
-->
<allow roles="UserEdits"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

Any help would be gratefully appreciated.

Thanks,
Tony