Defensive programming (ie. checking object for null before having an action on it) can be a great tool but do we always can prevent all the errors especially when it comes to user inputs or web servers that not always reliable. When application is up and running there are not many ways we can find out that some user had an error unless the error is global so application goes down. Of course if we have an access to Windows Event Viewer on the server we can check it daily but in my honest opinion Event Viewer is quite hard to use. Instead of that we can write our own ErrorLogger. So each time user or server have a bug we will have a nice report on that. For error tracking we will use .NET built in Exception class and Try and Catch block.
19
Sep 09
HOWTO: Properly connect to MSSQL database
There are many ways you can connect to a database in ASP.NET, the way i’m going to explain here based on “try and error” during my development years. I will try to explain why i do each step and what errors i had in the past so you may prevent these in your web applications. Experienced programmer should know each of these steps and may disagree so discussion is open to debate.
18
Sep 09
HttpCombiner modifications for better usability
HttpCombiner is a HttpHandler 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 generated files, which makes you websites to load faster. You can download http handler from Microsoft’s website by clicking here and you can read Omar’s article on how to implement the handler here. Original handler written by Omar Al Zabir.
It took me few minutes to configure the handler to work, it is easy to use and well documented. So i advice you to read Omar’s post before continuing with modifications.
16
Sep 09
HOWTO: Force IE 7 rendering in IE 8
If you haven’t checked how your website looks like in Internet Explorer 8 this might be the time to do that, latest version of Microsoft’s browser have slightly different engine which can cause your site to be unusable. This code shows how to force Internet Explorer 8 to act like Internet Explorer 7 which reduces the amount of css and html tweaks you may need to add in order to have cross browser website.
15
Sep 09
HOWTO: Use C# and VB in the same project
You will get a compilation error if you will place C# and VB code along in App_Code directory. This little code snippet for web.config gives your compliper an ability to distinguish between languages. Some of you could ask, i use X language why should i start an application with native support for few ? Real life example explains why would you do that.
14
Sep 09
HOWTO: Access Session outside of the page’s live cycle
You cannot access Session object or any other object which resides in page’s life cycle from out of the scope functions .This follow OOP rules but sometimes complicate development process when you need to access session from external source. In this example i will examine the way i use at any project to hack OOP for my needs. Maybe there is a better solution but this is the best i’ve found so far.
13
Sep 09
HOWTO: Group rows by day in MSSQL
This trick is usually useful in statistic where you need to count or sum records based on record day. Using it will help you grouping rows by day or month depends on your needs.
12
Sep 09
HOWTO: Schedule MSSQL query task
Check the images below to learn how to create a scheduled mssql query task using Microsoft’s Sql Server Management Studio. Red zones are the most important for you to check or to click on and black zones are the ones you not supposed see because screenshots were taken from live server.
11
Sep 09
HOWTO: Loop though each query result or MSSQL for loop
Many times i found myself in trouble ( Beatles ???) when i needed to change sql tables design based on some conditional logic so i couldn’t use Insert Select technique simply because it doesn’t support if statements when i needed something beyond when condition abilities.
10
Sep 09
HOWTO: Redesign sql table using Insert Select technique
My requirement was to totally redesign the table when i couldn’t just perform delete and update tasks on it. In this example i create new table based on old table’s filtered result set.