Search This Blog

Wednesday, January 23, 2013

Set hour and minute to a date SQL Server


SQL Server > Datetime > Set hour and minute to a date

declare @d1 datetime

set @d1 = (Select DateAdd(hour, 6, cast(floor(cast(getdate() as float))as datetime)))
set @d1 = (Select DateAdd(minute, 45, @d1))

print @d1
Result:
Jan 23 2013 6:45AM







Full screen application (C#)

TopMost
Gets or sets a value indicating whether the form should be displayed as a topmost form.






private void Form1_Load(object sender, EventArgs e)
{
  this.MaximizeBox = false;
  this.MinimizeBox = false;
  this.TopMost = true;
  this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}

Tuesday, January 22, 2013

Stop Statement (VB.NET)

VB.Net > StatementsStop

Stop is a programmatic alternative to setting a breakpoint and suspends the execution. When the debugger finds Stop statement, it breaks execution of the program.

Note: Unlike End, it does not close any files or clear any variables.

Example:

Dim i As Integer
Dim j As Integer
For i = 1 To 100
 j = i + 1
 Stop
Next i







With...End With Statement (VB.NET)

VB.NET > Statements > With...End With

Executes a series of statements that repeatedly refers to a single object or structure.

By using With...End With, you can perform a series of statements on a specified object without specifying the name of the object multiple times.

Example:


Public Class Form1
  Private Class Customer
    Public Property Id As String
    Public Property Name As String
  End Class
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    With New Customer
      .Id = 1
      .Name = "Elsoft"
      MessageBox.Show(.Name)
    End With
  End Sub




Monday, January 21, 2013

Temporary Tables (SQL Server)

SQL Server > Temporary tables

Local temporary tables
  • visible only to their creators during the same connection to an instance of SQL Server
  • deleted after the user disconnects from the instance of SQL Server
  • local temporary table name is stared with hash ("#") sign.
Example

Create temporary table

    Global temporary tables

    • visible to any user and any connection after they are created
    • deleted when all users that are referencing the table disconnect from the instance of SQL Server
    • global Temporary tables name starts with a double hash ("##")





    Get parent row RadGridView Telerik

    Telerik > Windows Forms > Get parent row RadGridView

    Example: Get parent row RadGridView Telerik

    Dim oParentRow As GridViewDataRowInfo = grd.CurrentRow.ViewInfo.ParentRow








    Terminate application (VB.Net)

    VB.NET > Statements > End

    End  force the application to stop running.
    • closes files opened Open statement
    • clears all the application variables

    Example:

    End application on button click

    Public Class Form1

        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        End Sub

        Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
            If MsgBox("Do you want to exit?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                End
            End If
        End Sub

    End Class