Thursday, 26 September 2013

scrollHeight problems with IE8


scrollHeight property does not work on IE8 and older IE browsers.

The workaround is to call the property before using it.

var tbox = document.querySelectorAll('[id^="transtext"]');

            for (var i = 0; i < tbox.length; i++) {

                tbox[i].style.height = 'auto';

                //put this line to make it work

                tbox[i].scrollHeight;

                tbox[i].style.height = tbox[i].scrollHeight + 'px';

            }

Useful link:

Tuesday, 30 July 2013

Site on a stick


Today I explored the idea of getting Apache webserver on a memory stick using XAMPP software.


 
The problem with this approach is that an ASP website will need to be ported to run on apache.

To accomplish this we will have to use additional tools like:

http://sourceforge.net/projects/mod-aspdotnet - this looked outdated and probably is no longer supported

http://www.mono-project.com/ASP.NET - this should work, but not sure of commercial licencing.
 

To avoid this, its better to use IIS Express 7.5.


 

The other problem is how to install SQL server on the memory stick. It is possible to install the data file on the memory stick, but the software will still need to installed on the native machine.

It is possible to migrate SQL server to another database like SQL Server CE or MySQL and then port it to memory stick.
 

SQL CE does not support Stored procedures. So using SQL CE will imply rewriting all SPs in code using LINQ.
 

The other option is to install Windows 8 operating system on the memory stick.

http://www.microsoft.com/en-us/windows/enterprise/products-and-technologies/devices/windowstogo.aspx


You can then install IIS express and SQL Server express on the portable operating system.

Monday, 15 July 2013

Improving performance by using Snapshot isolation level


While working on the performance tuning on the my website, I was getting the following error:

Transaction (Process ID XXX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

To reduce this deadlock, I changed the default isolation level of the database to Snapshot.

ALTER DATABASE dBname

SET ALLOW_SNAPSHOT_ISOLATION ON

ALTER DATABASE dBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

ALTER DATABASE dBname SET READ_COMMITTED_SNAPSHOT ON;

ALTER DATABASE dBname SET MULTI_USER;
 
I then changed the webservice calls to the database, such that the transaction scope for all read operations is set to IsolationLevel.Snapshot
 
var _transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Snapshot, Timeout = TimeSpan.FromMinutes(1) });

More information on snapshot isolation level can be found here:


It implements optimistic concurrency – such that user can read the last committed data, while its being modified.


 

Monday, 24 December 2012

MVC website performance

Faced with the challenge to improve the performance of our ASP MVC3 website, here is what I did:
  1. Added log messages in the controller and service layer calls - Since we use log4net for logging, this means simply adding Logger.Debug messages in the required methods. I made sure that the log took the time in millisecs, as seconds wasn't good enough! http://logging.apache.org/log4net/
  2. IE9 has a very useful addition to its Developer tools (F12), which is an additional tab for network monitoring. http://msdn.microsoft.com/en-gb/library/ie/gg589507(v=vs.85).aspx
This helped me realise that the performance bottleneck was not the database or business logic, but the response time - which meant HTML/Javascript sent to the client was enormous. One step which made a massive difference in reducing the response time was to enable HTTP dynamic compression in IIS Manager on our web server.
http://technet.microsoft.com/en-us/library/cc753681(v=ws.10).aspx
 

Saturday, 16 June 2012

Entity SQL and curly brackets


I came across this while working with ESQL. You may be trying to create a query as

String query = string.Format(“select a,b from tablename where a in {{0}}”, variablename)

This will not work as curly brackets needs to be escaped.

The easiest way to escape them is to add another curly brackets around the {0}, so it becomes {{{0}}}

Awkward, but works!


Monday, 21 May 2012

Change Data Capture

Change Data Capture is provided by SQL Server 2008. No more need for setting complicated triggers on your database object. It can make auditing database records so much easier.

The default retention value i.e. the time for which audit logs will be stored in the database is 4320 minutes = 72 hours = 3 days.
However it is configurable by using
sp_cdc_change_job @job_type='cleanup', @retention=minutes