Post Directly to Sql Database Problem

Topics: ASP.NET 2.0, Controls
Mar 26, 2009 at 12:21 PM
Hi

I am having some problems.  I want to post directly to the database in order to create my blog posts. I have another cms which I want to use and just do a direct insert into the be_posts table.

Before testing I have opened up the table in enterprise manager and entered some test data directly into the table. I then got the PostID and added it in the be_PostCategory table and assigned a categoryid.

I then went to the blog and Nothing appears :(

I thought it might be a date issue, so I inserted another post direct from the blog control panel and that post appeared. So I then changed my manually inserted dates to a couple of minutes behind this post.

Still Nothing :(

Am I missing the obvious like a setting somewhere which says - hey stupid this can't be done :)

I running ms sql server 2000 with windows 2003 server.  There are 70 odd posts in the table and working fine, but these were all posted via the blog control panel.

any suggestions or advice will be greatly appreciated

Coordinator
Mar 26, 2009 at 10:39 PM
It's probably not obvious, but BE isn't designed for data to be manually inserted into the DB or any XML files stored in the App_Data folder.

The reason is because when BE first starts up, it queries the DB to get all the posts and other data.  It then stores all those posts in memory so while people are on the blog, it doesn't need to go back to the DB.  So when you manually insert data into the DB, BE isn't aware that changes have been made.  Eventually when your blog re-starts or the data leaves the cache (after a long period of inactivity, app pool restart, server restart, etc), then BE will re-query the DB and see the new posts.
Mar 27, 2009 at 12:05 AM
Thanks this has helped alot.. I restarted IIS and if by magic my post appeared.

So do you know if there is a way of preventing blogengine pulling the data into memory? and reading directly from the db on request.

or is there a way to stimulate what happens when I insert a post via the blogengine admin area, because these manage to go live straight away

Coordinator
Mar 27, 2009 at 2:54 AM
This question gets asked pretty frequently, actually.  Here's some related threads.

http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=50352
http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=44544
http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=43734

As you'll see in some of these threads, there's not really an way to just turn off the caching BE does for posts and other data.  Plus, it probably wouldn't be ideal to re-read data from the DB on every request ... just because once you start accumulating so many posts, it won't be good performance wise for BE to keep re-querying the DB and putting all the blog posts into .NET objects, etc.

You could have a page or web service setup within BE that you call/hit whenever you manually add a blog post.  The page or web service could then re-load the posts from the DB.  This type of system is more ideal since BE only re-queries the DB when something changes.
Mar 27, 2009 at 2:24 PM
Thanks for the reply Ben.

Looks like you have been quite involved in these discussions.

thanks for your time

Nov 30, 2014 at 6:57 PM
Hi,

Is there any page or web service setup available within BE that can call/hit whenever manually blog post added ??