Thursday, August 26, 2010
Accessing Session Value in JavaScript
Friday, August 20, 2010
ACID Properties
- Atomicity—The transaction is all or nothing.
- Consistency—All constraints and other data integrity rules have been adhered to, and all related objects (data pages, index pages) have been updated completely.
- Isolation—Each transaction is completely isolated from any other transaction. The actions of one transaction cannot be interfered with by the actions of a separate transaction.
- Durability—After a transaction is completed, its effects are permanently in place in the system.
Thursday, August 19, 2010
Query for Max Salary and empname with managername
select a.id,a.name,b.name as 'mgrname',a.salary from
emp a left join emp b on(b.id=a.mgrid)
--Nth max salary
select * from emp e1 where (N-1)=(select count(distinct e2.salary) from emp e2
where e2.salary>e1.salary)
Tuesday, August 17, 2010
View State for TextBoxes, CheckBoxes, DropDownLists
There is a common misunderstanding among developers that view state is somehow responsible for having TextBoxes, CheckBoxes, DropDownLists, and other Web controls remember their values across postback. I was one of them.
This is not the case, because the values are identified via posted back form field values, and assigned in the LoadPostData() method for those controls that implement IPostBackDataHandler.
In the page lifecycle, LoadPostBackData happens after LoadViewState stage. They are independent. The value of a textbox is restored in LoadPostBackData stage. If the view state for this textbox is enabled, then what happens in LoadViewState? Yes, the textbox could got a value, but that could be the wrong one, because the information in the view state represents the state before submission. For example, if the textbox’s value is “Hello my world” before you take any action to the page; at this moment, in the viewstate, it is “Hello my world”. Then from the browser, you change it to “Hello your world”, and submit the page. A new trip of the page life cycle happens. As we have known now, LoadViewState happens before LoadPostBackData. Guess what is the textbox’s value in the LoadViewState stage gotten from view state? It is “Hello my world” rather than “Hello your world”. Fortunately, LoadViewState follows, so that you can get the correct “Hello your world”. Untill the moment before the control is rendered, the viewstate is updated to “Hello your world”. Have you seen enabling the ViewState for such a control only wastes the resource if your application cares performance a lot?
Here we only talk about changing the value for this textbox. If we need to change it’s BackColor, for example, then viewstate is useful; or use other method to remember the changed BackColor if ViewState is not enabled.
Here is the list of controls which could be form fields meanwhile implement IpostBackDataHandler. CheckBox, DropDownList, ImageButton, ListBox, RadioButton, TextBox.