Exception on default branch when add new post

Jul 19, 2014 at 8:13 PM
Edited Jul 19, 2014 at 8:13 PM
When i run the nearforum and add a post, if I don't set the tags, the exception is throw:
The TopicTags column of Topics table has not nullable column.
The exception can be resolved ?

System.Data.SqlClient.SqlException was unhandled by user code
Message=Impossible d'insérer la valeur NULL dans la colonne 'TopicTags', table 'Forums.dbo.Topics'. Cette colonne n'accepte pas les valeurs NULL. Échec de INSERT.
Source=.Net SqlClient Data Provider
   à System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   à System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   à System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   à System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   à System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   à System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   à System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   à System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   à System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   à NearForums.DataAccess.AdoExtensions.SafeExecuteNonQuery(DbCommand comm) dans c:\Work\Codeplex\nf\solution\NearForums.DataAccess\AdoExtensions.cs:ligne 244
   à NearForums.DataAccess.BaseDataAccess.SafeExecuteNonQuery(DbCommand comm) dans c:\Work\Codeplex\nf\solution\NearForums.DataAccess\BaseDataAccess.cs:ligne 149
   à NearForums.DataAccess.TopicsDataAccess.Add(Topic topic, String ip) dans c:\Work\Codeplex\nf\solution\NearForums.DataAccess\TopicsDataAccess.cs:ligne 194
   à NearForums.Services.TopicsService.Create(Topic topic, String ip, User user) dans c:\Work\Codeplex\nf\solution\NearForums.Services\TopicsService.cs:ligne 101
   à NearForums.Web.Controllers.TopicsController.Add(String forum, Topic topic, Boolean notify, String email) dans c:\Work\Codeplex\nf\solution\NearForums.Web.Controllers\TopicsController.cs:ligne 133
   à lambda_method(Closure , ControllerBase , Object[] )
   à System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   à System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   à System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   à System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   à System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
Aug 7, 2014 at 9:42 PM
Im not getting that expection when I try and post a new thread without tags.

I just get a message just above the Subject , telling me that i need tags.
Aug 9, 2014 at 9:49 PM
On current version in source code there are a comment on RequireField that cause this bug.
Look in Topic.cs in NearForums project.
        [RegexFormat(@"^\s*([\w\-\.]+(\s+|$)){1,6}$", RegexOptions.IgnoreCase)]
        public TagList Tags
Aug 10, 2014 at 2:09 PM
Edited Aug 10, 2014 at 2:43 PM
What did you type in the Tag field, to get the error message?
  1. If you just let tag field be empty when posting a new thread you will get an intentionally fail msg just above the subject field.
  2. RegexFormat just tells that:
^ = Begin String
\s* = Start of string can contain numerous amounts of space


\w = Literal or digit or underscore
\- = 
\. = Any character


\s+ = One or more space
|$ = Or end of string

{1,6} = Min and Max amounts of tags for each post
$ = End of String
  1. Read more here: Regular Expressions Syntax
Aug 10, 2014 at 3:06 PM
With empty value in Tag field,
The bug is that I don't have the msg above the subject field, I have only the exception on full screen.
On 733 revision the RequireField attribute has been commented, and is the cause of this exception.
If I uncomment this attribute, I have not the exception.
I have make two test and look the different result

WITHOUT RequiredField:
WITH RequireField :

Actually on 734 revision this line is commented and produce this bug.
I think,
Aug 10, 2014 at 3:14 PM
Edited Aug 10, 2014 at 3:16 PM
The regex accept emtpy value, no ?
Aug 11, 2014 at 4:52 PM
Edited Aug 11, 2014 at 4:53 PM
The regex accept spaces but not empty Line. You should try Update the jquery scripts. Are you using visual studio.?
Aug 15, 2014 at 4:23 PM
Sorry but the client validation is not enable on this form when I'am test, I have test on http://forum.darkshiftstudios.com/news/ too and the client validation is not activate, so the Jquery version does not affect the good or bad behavior,
I use viusal studio 2013.
Aug 17, 2014 at 2:07 PM
Its because i've not removed RequiredField attribute. It still stands as //RequiredField in Topic.cs

Have you looked into the TinyMCE feature?
Maybe I could add you on skype or some other social media, so that we can share information about nearforums?
Jul 20, 2015 at 9:46 AM
What did you type in the Tag field, to get the error message?
If you just let tag field be empty when posting a new thread you will get an intentionally fail msg just above the subject field.
RegexFormat just tells