Wednesday, December 28, 2011

iPad 2 :- Discovering Secret Tips and Tricks

iPad 2 Survival Guide Video Series


Monday, December 12, 2011

Changing Crystal Report Sort Order Programatically

Problem : - To sort crystal report programatically

Solution : -
Every report can have many types of fields that are used to generate the report, but don't have to appear directly on the report. Some examples are grouping fields, parameter fields, and formula fields. Even though these fields may not be shown directly on the report, they are updateable during runtime and can be used to change the report’s appearance. For example, you can change the sorting order of the report so that the report sorts and summarizes in a new way. The DataDefinition class manages the collections that control these aspects of the report.

You must already have the report sorted by something, or you will get error "Invalid sort number". If you haven't already, store a default sort order within your report, using Record Sort Expert from the Report menu


CrRptSrc is the Crystal Report Source

// Load Crystal Report
CrRptSrc.ReportDocument.Load(Report Path)

// Set parameters if any

// Set Record Selection Formula if any
CrRptSrc.ReportDocument.RecordSelectionFormula = "RSF"

// Sorting
Dim sortfield As CrystalDecisions.CrystalReports.Engine.FieldDefinition

sortfield = CrRptSrc.ReportDocument.Database.Tables("TableName").Fields("FieldName")

CrRptSrc.ReportDocument.DataDefinition.SortFields(index).Field = sortfield

CrRptSrc.ReportDocument.DataDefinition.SortFields(index).SortDirection = CrystalDecisions.Shared.SortDirection.AscendingOrder

// Report Logon information
CrRptSrc.ReportDocument.SetDatabaseLogon(userid , password)

// Print Report as PDF
CrRptSrc.ReportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, False, "")


Thursday, December 8, 2011

SEO Tips & Tricks


Samsung Galaxy S2 Tips & Tricks

Samsung Galaxy S2 Tips & Tricks


Tip: - Disable Submit button using Javascript

A simple function for disabling the Submit button inorder to avoid multiple clicks by user.

function disableSubmit(whichButton)
            if (document.getElementById)
               // this is the way the standards work
               document.getElementById(whichButton).disabled = true;
           else if (document.all)
               // this is the way old msie versions work
              document.all[whichButton].disabled = true;
          else if (document.layers)
              // this is the way nn4 works
             document.layers[whichButton].disabled = true;

Wednesday, December 7, 2011

ASP.NET Tip: Converting DataReader to Dataset

A simple function which converts the DataReader to DataSet.

public static DataSet ConvertDataReaderToDataSet(SqlDataReader reader)

          DataSet dataSet = new DataSet();
               // Create new data table
              DataTable schemaTable = reader.GetSchemaTable();
              DataTable dataTable = new DataTable();
              if ( schemaTable != null )
             {  // A query returning records was executed
                 for ( int i = 0; i < schemaTable.Rows.Count; i++ )
                           DataRow dataRow = schemaTable.Rows[ i ];
                           // Create a column name that is unique in the data table
                           String columnName = ( string )dataRow[ "ColumnName" ]; //+ "

                          // Add the column definition to the data table
                          DataColumn column = new DataColumn( columnName, ( Type )dataRow[ "DataType" ] );

                         dataTable.Columns.Add( column );
               dataSet.Tables.Add( dataTable );
               // Fill the data table we just created
               while ( reader.Read() )
                     DataRow dataRow = dataTable.NewRow();
                     for ( int i = 0; i < reader.FieldCount; i++ )
                            dataRow[ i ] = reader.GetValue( i );
                    dataTable.Rows.Add( dataRow );

               // No records were returned
             DataColumn column = new DataColumn("RowsAffected");
            dataSet.Tables.Add( dataTable );

            DataRow dataRow = dataTable.NewRow();
           dataRow[0] = reader.RecordsAffected;

          dataTable.Rows.Add( dataRow );
  while ( reader.NextResult() );
  return dataSet;


Javascript Tip: Check all checkboxes

A simple javascript function to check all checkboxes

function CheckAll(ctrl, checkVal)
      var i=0;

      var j=0;
      var k=0;
      var outerTR;
      var outerTD;

      var eleTbody=document.getElementById('uctrlConfigs_'+ctrl).children[0];

      for (i=0;i< eleTbody.children.length;i++)
           for (j=0;eleTR.children.length;j++)
                var innertab=eleTR.children[j].children[0].children[0];
                for(k=0;k< innertab.children.length;k++)


Oracle Tip: Delete All Rows from All Tables in a Database

Query to delete all rows of each & every table in a database.

This will be useful if you want to clear your database for test environment.



WHILE @@Fetch_Status = 0
           SET @SQL_STR = 'DELETE FROM DBO.'+@TableName+''
           BEGIN TRY
                        BEGIN TRANSACTION

                                     EXEC (@SQL_STR)
                        COMMIT TRANSACTION
           END TRY

           BEGIN CATCH
                        ROLLBACK TRANSACTION
           END CATCH

           FETCH NEXT FROM CUR INTO @TableName

Tip: Facebook Shortcut Keys

Shortcut Keys that can be used in Facebook

Shift+Alt+1 : Return to Home
Shift+Alt+2 : To view the Wall tab
Shift+Alt+3 : To pull down the Friends Requests list
Shift+Alt+4 : To retrieve the Messages list
Shift+Alt+5 : To call out the Notification list
Shift+Alt+6 : Account setting page
Shift+Alt+7 : Account privacy configuration.
Shift+Alt+8 : Facebook fans group page
Shift+Alt+9 : Facebook’s Statement of Rights and Responsibilities
Shift+Alt+0 : Facebook Help Center
Shift+Alt+m : Create new message
Shift+Alt+? : Cursor in the Search Box

Here is the list of Keyboard Shortcut combinations which you could try in Facebook by using Google Chrome.

Alt+1 : Return to Home
Alt+2 : To view the Wall tab
Alt+3 : To pull down the Friends Requests list
Alt+4 : To retrieve the Messages list
Alt+5 : To call out the Notification list
Alt+6 : Account setting page
Alt+7 : Account privacy configuration.
Alt+8 : Facebook fans group page
Alt+9 : Facebook’s Statement of Rights and Responsibilities
Alt+0 : Facebook Help Center
Alt+m : Create new message
Alt+? : Cursor in the Search Box

Oracle Tip : Multiple Like Conditions

I had a scenario for searching employee details based on comma seperated keywords entered by user.
I was searching for something that can solve my scenario in a single like condition and luckily I found "REGEX_LIKE"

REGEXP_LIKE is similar to the LIKE condition, except REGEXP_LIKE performs regular expression matching instead of the simple pattern matching performed by LIKE. This condition evaluates strings using characters as defined by the input character set.

Syntax of REGEXP_LIKE is  REGEXP_LIKE(sourcestring, pattern, matchparameter)
  • sourcestring is a character expression that serves as the search value
  • pattern is a regular expression
  • matchparameter is a text literal that lets you change the default matching behavior of the function eg. "i" for case insensitive, "c" for case sensitive etc.
For Eg. If I want to Select all the employees whose name starts with AB, SI, RO then

Select * from Employee where REGEXP_LIKE (Emp_Name ,'^(AB|SI|RO)','i');
If you would like to explore more Please Click Here

Sorted Months in a Crystal Report CrossTab

I was creating a summary report for our helpdesk system which shows the service engineer summary for a particular period . My output is as follows

Problem : - For displaying months as columns and it should be in a order as jan, feb , mar, april, But it was displaying based on the alphabetical order.
                   e.g. Apr, Aug, Feb, Jun, Jul etc...

Solution:- Inorder to achieve this

1) I changed my query to have monthnumber as well as monthname as two different fields
    eg:- MonthNo            Months          
          ----------            --------------
               1                     JAN
               2                     FEB
               3                     MAR
               4                     APR
2) Added monthnumber in Columns fields (Cross Tab Expert)

3) Sorted Months in Ascending Order 

4) Selected group label display as monthname.


Tuesday, December 6, 2011

Disable aspx button by checking validators

Scenario: - Check whether any validator is triggered. If triggered then don't postback and don't disable the button. If all validators are valid then disable the button and call the server side event.

To solve this scenario , I found out one simple solution using javascript

<script type="text/javascript" language="javascript">
function fnValidate(obj)
for(var i=0; i<Page_Validators.length; i++)

if (Page_Validators[i].isvalid)

if (obj.disabled==true)
<%=Page.GetPostBackEventReference(btnSubmit)%> }



Call this javascript function in button's OnClientClick property as follows.

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="fnValidate(this);" CausesValidation="true" OnClick="btnSubmit_Click"/>