This project is read-only.

Duplicate Messages posted by users

Sep 6, 2011 at 4:16 PM

I have a few times when Topics are posted two or more times with the same short names. When I delete the extra posts, the tags and the subscriptions I still receive and indexing error on the sql stmt. What steps should I take to delete duplicate posts?

Sep 7, 2011 at 9:58 AM

Hi Armanda,

I don't understand exactly what you mean...

Do you mean topics posted unintentionally more than once (for example the user clicks 2 times)? Or topics posted by 2 different users that speak about the same subject (and maybe you want to join them)?


Anyway, if you want to delete the topics manually you can go to the topic page (with moderation or admin rights) and click on delete...


Hope it helps,

Kind Regards,


Sep 7, 2011 at 5:09 PM

I can't get to the topic to delete it. I have this error

Server Error in '/' Application.

Invalid index 6 for this SqlParameterCollection with Count=6.

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.IndexOutOfRangeException: Invalid index 6 for this SqlParameterCollection with Count=6.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[IndexOutOfRangeException: Invalid index 6 for this SqlParameterCollection with Count=6.]
   System.Data.SqlClient.SqlParameterCollection.RangeCheck(Int32 index) +6381906
   System.Data.SqlClient.SqlParameterCollection.GetParameter(Int32 index) +22
   NearForums.DataAccess.TopicsDataAccess.GetRelatedTopics(Topic topic, Int32 amount) +452
   NearForums.ServiceClient.TopicsServiceClient.LoadRelatedTopics(Topic topic, Int32 amount) +49
   NearForums.Web.Controllers.TopicsController.Detail(Int32 id, String name, String forum, Int32 page) +181
   lambda_method(Closure , ControllerBase , Object[] ) +262
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826426
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826426
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825648
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

Sep 8, 2011 at 9:54 AM

Hi Armanda,

The error and stack trace you copied is from Topic Detail action (page which shows the detail of a topic, its messages and related topics) and is not related to deletion...

Could you provide more info that would let us help you?

For example: 

  • Web server (IIS 6; IIS 7; Apache)
  • Database server: (SQL Server; MySql)
  • Nearforums version and type of installation (manual or through the Web App Gallery)
  • Steps to reproduce the error.


Kind Regards,


Sep 14, 2011 at 9:57 PM

It has taken me some time to figure this one out. Try this to reproduce:

When you enter a topic, you  have to enter topic tags separated by spaces.
It seems that even though it does not say, the tag field will only tag field will only take 6 words or less.
If you enter 7, it kicks you to an error message but adds the message.
When you try to view a message that has more than 6 TopicTags you receive an error message.

If you go to the table and delete all but six tags, the message displays without a problem.

I posted two messages under Armanda in your sample forum. One with 6 tags and one with 7. The one with 7 will display in the topic list, but will not allow you to view the topic details. When I run SQL Profiler on my version of Near Forums the GetRElatedTags stored procedure does not run because it's caught by an sql collection index check because 6 is the max.


Make sense?

Sep 14, 2011 at 11:50 PM

The GetRelatedTopics fails. This is the code from TopicsDataAccess.cs


public List<Topic> GetRelatedTopics(Topic topic, int amount)
            List<Topic> list = new List<Topic>();
            DbCommand comm = GetCommand("SPTopicsGetByRelated");
            comm.AddParameter(this.Factory, "Tag1", DbType.String, null);
            comm.AddParameter(this.Factory, "Tag2", DbType.String, null);
            comm.AddParameter(this.Factory, "Tag3", DbType.String, null);
            comm.AddParameter(this.Factory, "Tag4", DbType.String, null);
            comm.AddParameter(this.Factory, "Tag5", DbType.String, null);
            comm.AddParameter(this.Factory, "Tag6", DbType.String, null);
            for (int i = 0; i < topic.Tags.Count; i++)
                comm.Parameters[i].Value = topic.Tags[i];
            comm.AddParameter(this.Factory, "TopicId", DbType.Int32, topic.Id);
            comm.AddParameter(this.Factory, "Amount", DbType.Int32, amount);
            DataTable dt = this.GetTable(comm);
            foreach (DataRow dr in dt.Rows)
                Topic t = ParseBasicTopicDataRow(dr);
                t.Forum = new Forum();
                t.Forum.Id = dr.Get<int>("ForumId");
                t.Forum.Name = dr.GetString("ForumName");
                t.Forum.ShortName = dr.GetString("ForumShortName");

            return list;


It is hard programmed to go to 6 then keeps adding. Yes?

The stored procedure looks like this:

ALTER PROCEDURE [dbo].[SPTopicsGetByRelated]
    @Tag1 varchar(50)='problem'
    ,@Tag2 varchar(50)='installation'
    ,@Tag3 varchar(50)='copy'
    ,@Tag4 varchar(50)=null
    ,@Tag5 varchar(50)=null
    ,@Tag6 varchar(50)=null
    ,@TopicId int=1
    ,@Amount int=5
WITH TagsParams (Tag) AS
    SELECT @Tag1
    SELECT @Tag2
    SELECT @Tag3
    SELECT @Tag4
    SELECT @Tag5
    SELECT @Tag6
    TOP (@Amount)
        ,COUNT(T.Tag) AS TagCount
        Tags T
        INNER JOIN TagsParams P ON T.Tag=P.Tag
    INNER JOIN TopicsComplete Topics ON Topics.TopicId = Ta.TopicId
    Topics.TopicId <> @TopicId
    1 desc, Topics.TopicViews desc


This is what creates the error when trying to view a topic.

Sep 15, 2011 at 9:04 AM

Great job seeking and reproducing the bug!!!

With all your the info you provided, I think we could fix it easily!


(Have you consider joining the nearforums dev team?)

Sep 15, 2011 at 12:50 PM

Thank you for the kind words.

There is also an error when you create the message if the tag textbox has more than 6 entries. I did not have time to track down all the pieces for that one. Maybe later today, unless you already know where it it.

Sep 15, 2011 at 3:37 PM

It is fixed now!

On the version branch and on the default branch

Released under v6.0.3.

I also updated the sample site.


We will update the Web deploy package used by the Windows Web App Gallery shortly.


Thanks a lot for your help!!!!