SQL Server

COALESCE function instead of long CASE WHEN … ELSE (T-SQL)

0

Instead of using long “SELECT … CASE WHEN … ELSE …” construction, you can use the COALESCE function when you need to find a value that is not NULL. Lets review the following T-SQL expression, in which we need to select an available “source”:

http://dotnettipoftheday.org/tips/sql-coalesce.aspx

SELECT TheSource =
   CASE
      WHEN localSource IS NOT NULL THEN localSource
      WHEN intranetSource IS NOT NULL THEN intranetSource
      WHEN internetSource IS NOT NULL THEN internetSource
      ELSE ''
   END
FROM ...

Now lets rewrite the code More >

.NET

Correct event invocation

0

http://dotnettipoftheday.org/tips/correct-event-invocation.aspx

Be aware that if there are no subscribers a .NET event will be null. Therefore when raising the event from C# test it for null first.


    public event EventHandler SelectedNodeChanged;

    protected virtual void OnSelectedNodeChanged(object sender, EventArgs e)
    {
        //Event will be null if there are no subscribers
        if (SelectedNodeChanged != null)
        {
            SelectedNodeChanged(this, e);
        }
    }

However in multithreaded application the last subscriber can unsubscribe immediately after the null check and before the event is raised. To avoid a null reference exception make a More >

.NET

C# Tips & Tricks

0

 

Office

Keyboard shortcuts for Word

0
   Command Name                  Shortcut Keys
   ------------------------------------------------------------------------

   All Caps                      CTRL+SHIFT+A
   Annotation                    ALT+CTRL+M
   App Maximize                  ALT+F10
   App Restore                   ALT+F5
   Apply Heading1                ALT+CTRL+1
   Apply Heading2                ALT+CTRL+2
   Apply Heading3                ALT+CTRL+3
   Apply List Bullet             CTRL+SHIFT+L
   Auto Format                   ALT+CTRL+K
   Auto Text                     F3 or ALT+CTRL+V
   Bold                          CTRL+B or CTRL+SHIFT+B
   Bookmark                      CTRL+SHIFT+F5
   Browse Next                   CTRL+PAGE DOWN
   Browse Previous               CTRL+PAGE UP
   Browse Sel                    ALT+CTRL+HOME
   Cancel                        ESC
   Center Para                   CTRL+E
   Change Case                   SHIFT+F3
   Char Left                     LEFT
   Char Left Extend              SHIFT+LEFT
   Char Right                    RIGHT
   Char Right Extend             SHIFT+RIGHT
   Clear                         DELETE
   Close or Exit                 ALT+F4
   Close Pane                    ALT+SHIFT+C
   Column Break

More >

SQL Server

SQL Server Date Formats

0
Standard Date Formats Date Format Standard SQL Statement Sample Output Mon DD YYYY 1 HH:MIAM (or PM) Default SELECT CONVERT(VARCHAR(20), GETDATE(), 100) Jan 1 2005 1:29PM 1 MM/DD/YY USA SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] 11/23/98 MM/DD/YYYY USA SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] 11/23/1998 YY.MM.DD ANSI SELECT CONVERT(VARCHAR(8), GETDATE(), 2) AS [YY.MM.DD] 72.01.01 YYYY.MM.DD ANSI SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD] 1972.01.01 DD/MM/YY British/French SELECT CONVERT(VARCHAR(8), GETDATE(), 3) AS [DD/MM/YY] 19/02/72 DD/MM/YYYY British/French SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY] 19/02/1972 DD.MM.YY German SELECT CONVERT(VARCHAR(8), GETDATE(), 4) AS

More >

Microsoft

Keyboard Shortcuts

0

Find keyboard shortcuts for the following Microsoft products:

Windows, Internet Explorer, Office 2010, Office 2007, Office 2003, More Office Keyboard Shortcuts, and Windows Media

http://www.microsoft.com/enable/products/keyboard.aspx

 

.NET

Visual Studio .NET 2003 Keyboard Shortcuts

0

Visual Studio .NET 2003 Keyboard Shortcuts

Global

Alt+- View ObjectBrowserBack Ctrl+- View NavigateBackward Ctrl+Shift+- View NavigateForward Shift+Alt+- View ObjectBrowserForward Ctrl+/ Tools GoToCommandLine Ctrl+Shift+1 View BrowseNext Ctrl+Shift+2 View BrowsePrevious Ctrl+Shift+8 View PopBrowseContext Ctrl+A Edit SelectAll Ctrl+Alt+A View CommandWindow Ctrl+Shift+A File AddNewItem Shift+Alt+A File AddExistingItem Ctrl+Alt+B Debug Breakpoints Ctrl+B Debug NewBreakpoint Ctrl+Shift+B Build BuildSolution Alt+Bkspce Edit Undo Ctrl+Alt+Break Debug BreakAll Ctrl+Break Build Cancel Ctrl+Alt+C Debug CallStack Ctrl+Shift+C View ClassView Ctrl+Alt+D Debug Disassembly Ctrl+D Edit GoToFindCombo Del Edit Delete Shift+Del Edit Cut Down Arrow Edit MoveControlDownGrid Shift+Down Arrow Edit SizeControlDownGrid

More >

.NET

Visual Studio .NET 2005 Keyboard Shortcuts

0

Visual Studio .NET 2005 Keyboard Shortcuts

Class Diagram

Num + ClassDiagram Expand Shift+Alt+B Edit ExpandCollapseBaseTypeList Ctrl+Del Edit Delete Del Edit RemovefromDiagram Enter View ViewCode Shift+Alt+L Edit NavigateToLollipop Num - ClassDiagram Collapse

DataSet Editor

Ins Data InsertColumn Ctrl+L Data Column

Deployment Designer

Shift+Alt+D Diagram RedrawConnection Shift+Alt+T Diagram RerouteConnection

Global

Ctrl+- View NavigateBackward Ctrl+Shift+- View NavigateForward Ctrl+. View ShowSmartTag Ctrl+/ Tools GoToCommandLine Ctrl+\, D View CodeDefinitionWindow Ctrl+\, E View ErrorList Ctrl+\, T View TaskList Ctrl+Shift+1 View BrowseNext Ctrl+Shift+2 View BrowsePrevious Ctrl+Shift+7 View ForwardBrowseContext Ctrl+Shift+8 View PopBrowseContext

More >

.NET

Visual Studio .NET 2008 Keyboard Shortcuts

0

Visual Studio .NET 2008 Keyboard Shortcuts

Class Diagram

Num + ClassDiagram Expand Shift+Alt+B Edit ExpandCollapseBaseTypeList Del Edit RemovefromDiagram Shift+Alt+L Edit NavigateToLollipop Num - ClassDiagram Collapse

DataSet Editor

Ins Data InsertColumn Ctrl+L Data Column

Global

Ctrl+- View NavigateBackward Ctrl+Shift+- View NavigateForward Ctrl+. View ShowSmartTag Ctrl+/ Edit GoToFindCombo Ctrl+Shift+1 View BrowseNext Ctrl+Shift+2 View BrowsePrevious Ctrl+5 Debug LocationToolbar Ctrl+6 Debug LocationToolbar Ctrl+7 Debug LocationToolbar Ctrl+Shift+7 View ForwardBrowseContext Ctrl+8 Debug LocationToolbar Ctrl+Shift+8 View PopBrowseContext Ctrl+9 Debug LocationToolbar Ctrl+A Edit SelectAll Ctrl+Shift+A Project AddNewItem Shift+Alt+A Project AddExistingItem Ctrl+Alt+B Debug Breakpoints

More >

windows-mobile-phone

.NET Compact Framework DateTime with Milliseconds

1

using System;
using System.Windows.Forms;

namespace DateTimeWithMilliSeconds
{
    public partial class Main : Form
    {
        private DateTime _startDateTime;
        private int _startTick;

        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            // Inialize with current DateTime and TickCount.
            _startDateTime = DateTime.Now;
            // TickCount returns the number milliseconds ellapsed since the system started.
            _startTick = Environment.TickCount;
        }

        private void btnGetDateTime_Click(object sender, EventArgs e)
        {
            lblDateTime.Text = GetDateTimeWithMilliSeconds().ToString("yyy.MM.dd HH:ss.fff");
        }

        /// <summary>
        /// Get DateTime with milliseconds
        /// </summary>
        /// <returns>DateTime</returns>
        public DateTime GetDateTimeWithMilliSeconds()
        {
            return _startDateTime.AddMilliseconds(Environment.TickCount - _startTick);
        }

    }
}
Go to Top