Cannot insert the value NULL into column 'DateTime'

Topics: Developer Discussion, Help, Request
Jun 19, 2007 at 4:38 AM
Does anyone know how to fix this:

Cannot insert the value NULL into column 'DateTime', table 'DB_1012911.dbo.HitCounter'; 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 'DateTime', table 'DB_1012911.dbo.HitCounter'; column does not allow nulls. INSERT fails.
The statement has been terminated.

Source Error:


Line 29: end if
Line 30:
Line 31: throw
Line 32:
Line 33: end try


Source File: d:\hosting\holytrinity1\UserControls\HitCounter.ascx Line: 31

Stack Trace:


[SqlException (0x80131904): Cannot insert the value NULL into column 'DateTime', table 'DB_1012911.dbo.HitCounter'; column does not allow nulls. INSERT fails.
The statement has been terminated.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857466
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735078
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
System.Data.SqlClient.SqlDataReader.get_MetaData() +62
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
ASP.HitCounter.Page_Load(Object sender, EventArgs e) in d:\hosting\holytrinity1\UserControls\HitCounter.ascx:31
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061


Thanks in advance.
dpr00
Coordinator
Jun 19, 2007 at 2:49 PM
Try deleting all the tables in the HitCounter table and try again.
Jun 19, 2007 at 7:35 PM
I deleted the hitcounter (I think this is a very helpful tool, but if it is creating problems for me then I will use other software).

Many of the errors I had I worked out by manually adding tables in the database.

My only problem now is that there is nothing in the aspnet_Roles table. I tried to copy application id and role id from local to server however got this error:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_aspnetRo_Appli_32E0915F". The conflict occurred in database "DB1012911", table "dbo.aspnetApplications", column 'ApplicationId'. The statement has been terminated.

Do you have the ID's that will work or do know how to create the proper ones? Need to become an administrator on site.

Any help appreciated.
dpr00
Coordinator
Jun 19, 2007 at 9:30 PM
Go in and use the ASP.NET Administration tool. It is sometimes a very bad thing if you mess with the ASP.NET membership stuff more than you have to.