The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPosts_Blogs".

Jul 16, 2009 at 8:24 PM

After creating a standard BlogEngine website I added the BE.SQL components and logged into the displayed blog as admin. When attempting to make a post, I got the error shown below.

How might I fix this?

Thanks

Richard

 

Server Error in '/' Application.

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPosts_Blogs". The conflict occurred in database "BlogEngine", table "dbo.be_Blogs", column 'BlogId'.
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 "FK_BlogPosts_Blogs". The conflict occurred in database "BlogEngine", table "dbo.be_Blogs", column 'BlogId'.
The statement has been terminated.

Source Error:

Line 235:		}
Line 236:
Line 237:		post.Save();
Line 238:
Line 239:		Session.Remove("content");


Source File: c:\inetpub\BlogEngine\admin\Pages\Add_entry.aspx.cs    Line: 237

Stack Trace:

[SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPosts_Blogs". The conflict occurred in database "BlogEngine", table "dbo.be_Blogs", column 'BlogId'.
The statement has been terminated.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +212
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2811
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6281084
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +6282273
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +424
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +522
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +182
   System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +328
   System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +207
   System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +576
   System.Data.Linq.StandardChangeDirector.DynamicInsert(TrackedObject item) +95
   System.Data.Linq.StandardChangeDirector.Insert(TrackedObject item) +220
   System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +342
   System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +659
   BlogEngine.SQLServer.SqlBlogProvider.InsertPost(Post post) in D:\Projects\Personal\BE.Net\BE.SQL Server\Trunk\BlogEngine.SQLServer\SqlBlogProvider.cs:203
   BlogEngine.Core.Post.DataInsert() +38
   BlogEngine.Core.BusinessBase`2.Update() +320
   BlogEngine.Core.BusinessBase`2.Save(String userName, String password) +194
   BlogEngine.Core.BusinessBase`2.Save() +29
   admin_entry.btnSave_Click(Object sender, EventArgs e) in c:\inetpub\BlogEngine\admin\Pages\Add_entry.aspx.cs:237
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981