Print Page | Close Window

An error has occurred while writing to the databas

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=31302
Printed Date: 29 March 2026 at 9:43am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: An error has occurred while writing to the databas
Posted By: jpullam2
Subject: An error has occurred while writing to the databas
Date Posted: 28 December 2015 at 1:13pm
I just received the following error message:

Server Error in Forum Application
An error has occurred while writing to the database.
Please contact the Forum Administrator.

Support Error Code:- err_SQLServer_getSessionData()_update_last_active_date
File Name:- functions_session_data.asp
Forum Version:- 11.04

There was no further detail provided. This is a SQL Server 2008 system, newly created, which has been live for around a week now. I also saw this error message a few days ago and I restored the database from a nightly backup, which I can do again.

My concern is that this may happen regularly, especially when over the past week there have been no postings, yet it failed overnight for the second time.

Is there anything I can do to get more info on the problem? Should my hosting company have more details in the server logs to follow up on? Any suggestions?




Replies:
Posted By: WebWiz-Bruce
Date Posted: 29 December 2015 at 9:00am
This is a very usual error message to occur.

The error is occurring when the date/time you are last active is updated in your forum session which is stored in the database.

The last active date is updated every 3 minutes and is used to remove old stale entries from the tblSession Table in the database.

I would check to make sure that your database is not full preventing modifications to the database.

If your database is running slow for any reason then this could also be the reason for this error.

You can also change the settings for forum members sessions so they are stored in memory instead of the database. This disadvantage to this is that members sessions would reset when the app pool for your website recycles.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 29 December 2015 at 3:26pm
I will change it to put the settings in memory. Hopefully that will reduce the frequency of failing and being unable to logon.

The database is located across the country from its users and there are times when the servers may be slow or down. Does your software do an update every 3 minutes, even when there is no activity for hours? 


Posted By: WebWiz-Bruce
Date Posted: 30 December 2015 at 8:56am
The update to the users session for their last activity would only occur when they move between pages and their last activity time is over 3 minutes ago.

Sessions which have a last activity time of over 20 minutes are removed.

If your database server is not located on the same network it is likely that the error is occurring due to the database update timing out. This could cause corruptions to the database if database updates are timing out.

I would advise to have the database server on the same network so that you do not get these delays which cause timeouts, but if you can not then you can increase the timeout for database connections by editing the file 'database\database_settings.asp' in a text editor and add the following to the end of SQL Server Database connection string around line 88;

Connection Timeout=90;Command Timeout=200;


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 04 January 2016 at 12:32am
I just checked the forums and received this new error message:

Server Error in Forum Application
An error has occurred while writing to the database.
Please contact the Forum Administrator.

Support Error Code:- err_SQLServer_getUserData()_update_last_visit
File Name:- functions_login.asp
Forum Version:- 11.04

It appears to me that no one besides me has used the forums since the conversion. There might be someone who has looked, but over the holidays there have been no posts.

I restored the database from the nightly backup and it is again working, but obviously I can't do this every few days. 

I am no longer storing the date/time in the database, so that shouldn't be it. I can't imagine what it is trying to do ...can you help?

Is there something that I need to get the SQL administrator at my web hoster to provide?

(And by the way, the SQL data base server and the IIS web server are inside the same data centre, so I don't think that it is a problem of connectivity between the two.)


Posted By: WebWiz-Bruce
Date Posted: 04 January 2016 at 8:39am
The issue sounds like a problem with the database server or the settings on your database server for the database.

If you have restricted the size of your database make sure that it has enough space assigned for the database to grow.

Also make sure that you have the database set to simple recovery mode.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 04 January 2016 at 1:42pm
The hosting tech support guy said:

We're seeing no other customers with a similar type of issue on the SQL Server that you are on. I also did a quick check of the SQL logs and didn't see anything in them regarding this database beyond the initial starting up database logs and other misc entries.

Can you tell me if there is anything we can do to intercept the underlying error the next time it occurs? Perhaps some SQL error data that can be recorded that would provide some insight into the specific condition in more technical terms?



Posted By: WebWiz-Bruce
Date Posted: 04 January 2016 at 1:54pm
'Detailed Error Reporting' can be enabled from the General settings page within the forum admin area which may give more detail on why you get this error.

You also mention a conversion. What do you mean by this? Did you migrate from another database type to SQL Server or from a different forum system?


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 04 January 2016 at 2:38pm
Yes. I just converted from Access and 7.9. Everything looks good otherwise, although there were a few glitches that had to be resolved.

I switched it to detailed error reporting which should help.


Posted By: WebWiz-Bruce
Date Posted: 04 January 2016 at 2:54pm
Shame you did not mention this in your original post as this would have pointed straight away to the issue.

The errors that you are reporting are highly unusual and should not occur.

It is therefore likely that the migration from Access to SQL Server did not work correctly and you have ended up with a database that is causing your forum to be unstable with these errors.

Access and SQL server handle dates in different ways and as the tables giving the errors are those that also rely on the date/time for updates I suspect that these fields have not be migrated correctly from Access.

I would advise to go back to your Access database and try the migration again. The Microsoft SQL Server Migration Assistant (SSMA) does a very good job of migrating the Web Wiz Forums Access database to SQL Server using the default settings, although you will still need to do some tweaking to the database after the migration.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: WebWiz-Bruce
Date Posted: 04 January 2016 at 3:00pm
You may also be interested in our Web Wiz Forums hosting packages;

http://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - https://www.webwiz.net/web-wiz-forums/forum-hosting.htm

In the migration service we offer with the hosted service our own developers can take your Access database and convert it to SQL Server 2014, fix any errors caused by the migration, and have your forum running stably on our servers without the issue you are presently facing.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 04 January 2016 at 3:34pm
I did use the Migration Assistant. Could you elaborate on the tweaking I might need to do?


Posted By: WebWiz-Bruce
Date Posted: 05 January 2016 at 9:22am
It does take a bit of an expert eye to do the tweaking, but the simplest way for you to do this is create an original Web Wiz Forums SQL Server Database and compare this against the migrated database that you have created.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 07 January 2016 at 3:15pm
My asp is a little rusty but I managed to track this down to the following...

There is a SQL update statement in functions_login.asp that after substitution becomes this:

UPDATE tblAuthor WITH (ROWLOCK) SET tblAuthor.Last_visit = '20160106 18:18:50' WHERE tblAuthor.Author_ID = 1;

When I execute this statement using SSMS, it fails the same way as the app so I am pretty sure I have nailed it. The field tblAuthor.Last_visit is defined in the SQL database as datetime2 which I am not familiar with. I normally code fields as datetime. I assume that the Microsoft conversion utility decided to make it datetime2 and that may be the problem.

When I added a field defined as datetime and applied the same query against it, it ran fine. So I am thinking of just deleting that column and recreating it as datetime.

Can you advise if there is anything wrong with that tweak as far as you know?


Posted By: WebWiz-Bruce
Date Posted: 08 January 2016 at 2:56pm
Rather than deleting the field go through the database and any fields with the data type datetime2 change to datetime data type.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: jpullam2
Date Posted: 11 January 2016 at 9:34pm
It's been 3 days without a problem so I wanted to put some closure to this issue and provide a bit of feedback on some of the comments made, in case others may find this posting because of similar issues.

1 - Was the problem the datetime2 specification versus datetime? I no longer think that was it. I successfully tried the same SQL query out on a datetime field in that table and it failed too.

2 - Change the type of all datetime fields to datetime2. You can't change the type because SSMS says you have to delete and add a new field. Fortunately I didn't need to do that.

3 - How did I fix it? My hoster suggested moving the database to SQL 2014 from SQL 2008, so he did an export and import and I changed the settings in the file database_settings.asp, From that point on, no errors. So maybe it was an issue converting the Access database which has been fixed in SQL 2014. Who knows?


Posted By: rune
Date Posted: 11 January 2016 at 11:32pm
Maybe your 2008 server was set to a country code where the time string  '20160106 18:18:50' doesn't make sense?


Posted By: WebWiz-Bruce
Date Posted: 12 January 2016 at 8:43am
Glad to hear that you fixed the issue.

Just to add you can change data types for fields in Microsoft SQL Server Management Studio but you have to first uncheck the option;

Prevent saving changes that require table re-creation

This option is disabled in 'Tools -> Designers' in Microsoft SQL Server Management Studio.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net