Search This Blog

Wednesday, June 6, 2012

Restart asp.net application

ASP.NET > HttpRuntime > UnloadAppDomain


HttpRuntime.UnloadAppDomain Method

Terminates the current application. The application restarts the next time a request is received for it.

UnloadAppDomain is useful for servers that have a large number of applications that infrequently receive requests. Rather than keep application resources alive for the lifetime of the process, UnloadAppDomain allows programmatic shutdown of unused applications.

Example

Restart asp.net application


using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace editor.Admin
{
    public partial class restart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.HttpRuntime.UnloadAppDomain();
        }
    }
}

 





Setting up a Sent Mail rule in Thunderbird

Setting up a Sent Mail rule in Thunderbird
1. Click on Tools > Account Settings
2. Under your Account Name (the example below shows Work Account, you may have simply named yours IMAP), select Copies and Folders

Make sure there is a tick next to Place a copy in: You then have TWO choices.
OPTION ONE
"Sent" folder on By default Thunderbird selects "Sent" folder on This means that Thunderbird will create a folder for you called Sent under your IMAP account and all your sent items will filter into this folder.
OPTION TWO
Other You may already have a Sent Mail folder set up on your IMAP account. By selecting Other you can specify which folder you would like your sent mail to filter into. To select an alternative folder: Click on the following icon: Select your Account Name (not Local Folders) Choose the Sent Mail folder you require
Click OK to save your changes.




Friday, February 18, 2011

Extract hour, minute from date column Oracle

Oracle > Extract hour, minute from date column

SELECT
  to_char(column_date,'HH24') hh
  ,to_char(column,'mi') min
from
  table;




Wednesday, February 2, 2011

SQL Server Deadlocks

SQL Server > Deadlocking

Deadlocking occurs when

  •  two user processes have locks on separate objects and each process is trying to acquire a lock on the object that the other process has.

SQL Server identifies the problem and ends the deadlock by: 


  • automatically choosing one process and aborting the other process
  • allowing the other process to continue.

The aborted transaction is rolled back and an error message is sent to the user of the aborted process.
Generally, the transaction that requires the least amount of overhead to rollback is the transaction that is aborted.

Avoid deadlocking on your SQL Server:

  • Ensure the database design is properly normalized.
  • Have the application access server objects in the same order each time.
  • During transactions, don't allow any user input.
  • Avoid cursors.
  • Keep transactions as short as possible.
  • Reduce lock time.
  • If appropriate, reduce lock escalation by using the ROWLOCK or PAGLOCK.
  • Consider using the NOLOCK hint to prevent locking if the data being locked is not modified often.
  • If appropriate, use as low of an isolation level as possible for the user connection running the transaction.









Thursday, December 30, 2010

Select a random records SQL SERVER, Oracle, MySql

Database > Random Records

--Select random rows with Microsoft SQL Server
--NEWID Creates a unique value of type uniqueidentifier.

SELECT * FROM table ORDER BY NEWID()

--Select random rows with MySQL
SELECT * FROM table ORDER BY RAND()

--Select random records with Oracle:
SELECT * FROM table ORDER BY dbms_random.value









How to extract words out from a string c#

C# > String > Spilt
 
Split returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array. 


Example
 
string _strInput = "aaa bbb ccc ddd";
string[] words = _strInput.Split ( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries );
foreach(string s in words)
{
  // value of s: aaa, bbb, ccc, ddd
}






Wednesday, September 1, 2010

Null data in Oracle using the ORDER BY clause

From:
Control null data in Oracle using the ORDER BY clause
Date: June 19th, 2007
Author: Bob Watkins

NULL data, which is sometimes called “absent” data, can be difficult to work with in relational databases. When a query contains the ORDER BY clause to sort the output, NULL data will sort to the bottom if the sort is in ascending order (ASC) and to the top if the sort is in descending order (DESC). In effect, NULL is treated as a very large value by Oracle.

This can create reports that are difficult to read. Consider a simple query in Oracle’s HR sample schema. Let’s say you want to list the names and commission percents of all employees in descending order, including those who get no commission (commission_pct is NULL). The following simple query does this:

SELECT employee_id, last_name, first_name, commission_pct
FROM employees
ORDER BY commission_pct DESC;

The problem is that all employees with no commission come out on top. You have to read through them all to find those who actually have a commission.

Starting with Oracle 8i, there is a little known syntax in the ORDER BY clause that fixes this. All you have to do is change the last line above to the following:

ORDER BY commission_pct DESC NULLS LAST;

The null rows will sort to the bottom after all the rows that contain commission data. You can also use NULLS FIRST when you’re sorting in ascending order, and you want the NULL rows to appear at the top of the report.

If you’re still supporting Oracle 8.0 or 7.3 databases, you can achieve the same effect using the Null Values function (NVL). Use something like the following in your ORDER BY:

ORDER BY NVL(commission_pct, -1);

This forces the NULL rows to be sorted as if they had the value (-1) in them, and they will appear at the bottom of the output. You won’t see the (-1) values because the query only sorts by the NVL function — it doesn’t display it in the SELECT lis