Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 19th, 2007, 02:18 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in AddEditArticle.aspx

When I try to add an article to the AddEditArticle.aspx page I get ViewCount cannot be null exception.

 Cannot insert the value NULL into column 'ViewCount', table 'C:\WEBSITES\VIBESCARDOMAIN\APP_DATA\ASPNETDB.MDF. dbo.tbh_Articles'; column does not allow nulls. INSERT fails.
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: Cannot insert the value NULL into column 'ViewCount', table 'C:\WEBSITES\VIBESCARDOMAIN\APP_DATA\ASPNETDB.MDF. dbo.tbh_Articles'; column does not allow nulls. INSERT fails.
The statement has been terminated.

Source Error:

Line 111: }
Line 112: else
Line 113: return cmd.ExecuteNonQuery();
Line 114: }
Line 115:


Source File: c:\Websites\VibesCarDomain\App_Code\DAL\DataAccess .cs Line: 113

Stack Trace:

[SqlException (0x80131904): Cannot insert the value NULL into column 'ViewCount', table 'C:\WEBSITES\VIBESCARDOMAIN\APP_DATA\ASPNETDB.MDF. dbo.tbh_Articles'; column does not allow nulls. INSERT fails.
The statement has been terminated.]
   System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) +95
   System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) +82
   System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) +346
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3244
   System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +186
   System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1121
   System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
   System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +407
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149
   MB.VibesDomain.DAL.DataAccess.ExecuteNonQuery(DbCo mmand cmd) in c:\Websites\VibesCarDomain\App_Code\DAL\DataAccess .cs:113
   MB.VibesDomain.DAL.SqlClient.SqlArticlesProvider.I nsertArticle(ArticleDetails article) in c:\Websites\VibesCarDomain\App_Code\DAL\SqlClient\ SqlArticlesProvider.cs:313
   MB.VibesDomain.BLL.Articles.Article.InsertArticle( Int32 categoryID, String title, String Abstract, String body, String country, String state, String city, DateTime releaseDate, DateTime expireDate, Boolean approved, Boolean listed, Boolean commentsEnabled, Boolean onlyForMembers) in c:\Websites\VibesCarDomain\App_Code\BLL\Articles\A rticle.cs:561

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(Objec t target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +358
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
   System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +676
   System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSourceMethod method) +60
   System.Web.UI.WebControls.ObjectDataSourceView.Exe cuteInsert(IDictionary values) +827
   System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +173
   System.Web.UI.WebControls.DetailsView.HandleInsert (String commandArg, Boolean causesValidation) +625
   System.Web.UI.WebControls.DetailsView.HandleEvent( EventArgs e, Boolean causesValidation, String validationGroup) +745
   System.Web.UI.WebControls.DetailsView.OnBubbleEven t(Object source, EventArgs e) +163
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
   System.Web.UI.WebControls.DetailsViewRow.OnBubbleE vent(Object source, EventArgs e) +118
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
   System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +106
   System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String eventArgument) +175
   System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +32
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +244
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3835
 
Old February 20th, 2007, 06:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's hard to ask for more info from an error message. Please read it slowly and try breakpoints to see what the param values are. You know the source file and line number, and the stack trace shows you the context.

Eric

 
Old May 31st, 2007, 04:14 PM
Authorized User
 
Join Date: Jan 2007
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get this exact same error. I think I've narrowed it down to the fact that the "tbh_Articles_InsertArticle" stored procedure doesn't insert values for ViewCount (nor Votes or TotalRating). The problem is, the book says that ViewCount can't be left blank (can't accept nulls).

What should be done? Will there be negative repercussions if I simply allow nulls? Or, should I put starting values (i.e. zeros) in the insert statement?

 
Old May 31st, 2007, 08:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

These columns were defined with a default value of 0. This forces the table to insert a 0 anytime a NULL is passed in for that column. If your tables don't have these defaults specified you can add them in SQL like this:

alter table tbh_articles add constraint DFLT0 default (0) for votes






Similar Threads
Thread Thread Starter Forum Replies Last Post
AddEditArticle.aspx retroviz BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 February 19th, 2008 12:33 PM
AddEditArticle.aspx - validation error emilypost BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 May 31st, 2007 02:55 PM
error in default.aspx anass BOOK: ASP.NET Website Programming Problem-Design-Solution 1 June 24th, 2005 09:02 PM
aspx error message... haghill ASP.NET 1.0 and 1.1 Basics 3 July 22nd, 2003 10:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.