Search This Blog

Monday, January 14, 2013

Duplicate rows in Oracle

Oracle > Scripts

SQL Query to find duplicate rows in Oracle

SELECT
  *
FROM
  table_name A
WHERE
  A.rowid >
  ANY (SELECT B.rowid FROM  table_name B WHERE
             A.col1 = B.col1
            AND
             A.col2 = B.col2
             )




Export to Excel Hierarchial data in the RadGridView

Telerik > RadGridView

ExportToExcelML method exports an image of an element to Excel file

ExportHierarchy property set if child rows should be exported


Example:

ExportToExcelML excelExporter = new ExportToExcelML(radGridView);
excelExporter.ExportHierarchy = true;
excelExporter.RunExport(filePath);





Concatenate string VB.NET

VB.NET > String > Concatenate

You can use +, & operators and Concat method.
Concat concatenates one or more instances of String.

The + and & operators are not identical in VB.NET.
  • & is only used for string concatenation
  • + is overloaded to do both string concatenation and arithmetic addition.

Example

1. Using & operator with strings

Dim str1 As String = "Visual "
Dim str2 As String = "Basic"
' Concatenate
Dim str3 = str1 & str2
MessageBox.Show(str3)


 
2. Using & operator with string and number

Dim str1 As String = "Visual Basic "
Dim str2 As Integer = 6

' Concatenate
Dim str3 = str1 & str2
MessageBox.Show(str3)


3. Concat Method

Dim str1 As String = "Visual"
Dim str2 As Integer = 6
' Concatenate
Dim str3 = String.Concat(str1, " ", str2)
MessageBox.Show(str3)





Thursday, January 10, 2013

First and Last day of a Month VB .NET

VB.NET > Functions > > DateSerial

Returns a Date value representing a specified year, month, and day, with the time information set to midnight (00:00:00).

Examples


First and last day of a month

VB.net
' first day of month
FirstDay = DateSerial(Today.Year, Today.Month, 1)
' month's last day
LastDay = DateSerial(Today.Year, Today.Month , 0)

C#

DateTime firstDayOfTheMonth = new DateTime(DateTime.Today.Year,DateTime.Today.Month, 1);
DateTime lastDayOfTheMonth = firstDayOfTheMonth.AddMonths(1).AddDays(-1);






Tuesday, January 8, 2013

Add Rows to RadGridView WinForms VB.NET

Telerik > RadGridView > Rows

GridViewRowInfo is the logical representation of a single row.

Examples

1. Add rows

You can add rows by creating an instance of GridViewDataRowInfo and adding it to the Rows collection of RadGridView

Dim rowInfo As New GridViewDataRowInfo(Me.RadGridView1.MasterView)
rowInfo.Cells(0).Value = "new row"
RadGridView1.Rows.Add(rowInfo)





Friday, January 4, 2013

Print RadGridView Telerik Windows Forms (VB.NET)

Telerik > Windows Forms > Print RadGridView

RadPrintDocument
Defines a reusable object that sends output to a printer and manages the whole printing process, when printing from an application

PrintPreviewDialog
Represents a dialog box form that contains a PrintPreviewControl for printing from a Windows Forms application.

AssociatedObject
 Gets or sets the object, associated with this document.

Print directly

Example:

Dim dialog As New PrintPreviewDialog
Dim RadPrintDocument1 As New RadPrintDocument
RadPrintDocument1.AssociatedObject = Me.RadGridView1
RadPrintDocument1.MiddleHeader = lblTitle.Text
RadPrintDocument1.MiddleFooter = "Page [Page #] of [Total Pages]"
RadPrintDocument1.RightFooter = "[Date Printed]"
dialog.Document = RadPrintDocument1
dialog.StartPosition = FormStartPosition.CenterScreen
dialog.ShowDialog()





Friday, December 28, 2012

Key events not fired Windows Forms

C# > Form > KeyPreview 

KeyPreview gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.






Example

Key events not fired Windows Forms

Solution:

Set KeyPreview property to True