21
Sep 09

HOWTO: Log website errors using exceptions in ASP.NET

Defen­sive pro­gram­ming (ie. check­ing object for null before hav­ing an action on it) can be a great tool but do we always can pre­vent all the errors espe­cially when it comes to user inputs or web servers that not always reli­able. When appli­ca­tion is up and run­ning there are not many ways we can find out that some user had an error unless the error is global so appli­ca­tion goes down. Of course if we have an access to Win­dows Event Viewer on the server we can check it daily but in my hon­est opin­ion Event Viewer is quite hard to use.  Instead of that we can write our own Error­Log­ger. So each time user or server have a bug we will have a nice report on that. For error track­ing we will use .NET built in Excep­tion class and Try and Catch block.

Con­tinue reading →


19
Sep 09

HOWTO: Properly connect to MSSQL database

There are many ways you can con­nect to a data­base in ASP.NET, the way i’m going to explain here based on “try and error” dur­ing my devel­op­ment years. I will try to explain why i do each step and what errors i had in the past so you may pre­vent these in your web appli­ca­tions. Expe­ri­enced pro­gram­mer should know each of these steps and may dis­agree so dis­cus­sion is open to debate.

Con­tinue reading →


18
Sep 09

HttpCombiner modifications for better usability

Http­Com­biner is a HttpHan­dler allows you to gather all css and js files together which decreases amount of http requests made to server when user requests a page and also to cache the gen­er­ated files, which makes you web­sites to load faster. You can down­load http han­dler from Microsoft’s web­site by click­ing here and you can read Omar’s arti­cle on how to imple­ment the han­dler here. Orig­i­nal han­dler writ­ten by Omar Al Zabir.

It took me few min­utes to con­fig­ure the han­dler to work, it is easy to use and well doc­u­mented. So i advice you to read Omar’s post before con­tin­u­ing with modifications.

Con­tinue reading →


16
Sep 09

HOWTO: Force IE 7 rendering in IE 8

If you haven’t checked how your web­site looks like in Inter­net Explorer 8 this might be the time to do that, lat­est ver­sion of  Microsoft’s browser have slightly dif­fer­ent engine which can cause your site to be unus­able. This code shows how to force Inter­net Explorer 8 to act like Inter­net Explorer 7 which reduces the amount of css and html tweaks you may need to add in order to have cross browser website.

Con­tinue reading →


15
Sep 09

HOWTO: Use C# and VB in the same project

You will get a com­pi­la­tion error if you will place  C# and VB code along in App_Code direc­tory. This lit­tle code snip­pet for web.config gives your com­pliper an abil­ity to dis­tin­guish between lan­guages.  Some of you could ask, i use X lan­guage why should i start an appli­ca­tion with native sup­port for few ? Real life exam­ple explains why would you do that.

Con­tinue reading →


14
Sep 09

HOWTO: Access Session outside of the page’s live cycle

You can­not access Ses­sion object or any other object which resides in page’s life cycle from out of the scope func­tions .This fol­low OOP rules but some­times com­pli­cate devel­op­ment process when you need to access ses­sion from exter­nal source. In this exam­ple i will exam­ine the way i use at any project to hack OOP for my needs. Maybe there is a bet­ter solu­tion but this is the best i’ve found so far.

Con­tinue reading →


13
Sep 09

HOWTO: Group rows by day in MSSQL

This trick is usu­ally use­ful in sta­tis­tic where you need to count or sum records based on record day. Using it will help you group­ing rows by day or month depends on your needs.

Con­tinue reading →


12
Sep 09

HOWTO: Schedule MSSQL query task

Check the images below to learn how to cre­ate a sched­uled mssql query task using Microsoft’s Sql Server Man­age­ment Stu­dio. Red zones are the most impor­tant for you to check or to click on and black zones are the ones you not sup­posed see because screen­shots were taken from live server.

Con­tinue reading →


11
Sep 09

HOWTO: Loop though each query result or MSSQL for loop

Many times i found myself in trou­ble ( Bea­t­les ???) when i needed to change sql tables design based on some con­di­tional logic so i couldn’t use Insert Select tech­nique sim­ply because it doesn’t sup­port if state­ments when i needed some­thing beyond when con­di­tion abil­i­ties.

Con­tinue reading →


10
Sep 09

HOWTO: Redesign sql table using Insert Select technique

My require­ment was to totally redesign the table when i couldn’t just per­form delete and update tasks on it. In this exam­ple i cre­ate new table based on old table’s fil­tered result set.

Con­tinue reading →