Pages

Sunday, 28 October 2012

Difference between Convert.ToString() and object.ToString()?

Both statement are use to convert into string but the main difference is in handling of NULL value.
Convert.ToString() : It handles NULL reference exception.
.ToString() : It doesn’t handle NULL reference exception.
 So for good programming practice, always use Convert.ToString() for safety.

Code Snippet :
// Throws exception
int salary = null;
string oldSalary = salary.tostring();

// Return NULL value
int salary = null;
string oldSalary = Convert.ToString(salary);

 






Saturday, 27 October 2012

Debug Error : No symbols have been loaded for this document.

Many days ago i found very wired issue while debugging and i wasted much time in googling to solve it out and after solved it i found that it was very minor issue.

Issue : I worked on windows service and after install it, i want to debug that windows service so first i attached that service process to debug it using (Ctrl C+P) in visual studio and i got below error message.

Error : The breakpoint will not currently be hit. No symbols have been loaded for this document.”


Solution : I found many solution from internet but solution works for me is listed below:
Its due to my application made in framework version 4.0 and i was trying to attach process with version below v2.0 so make sure your framework version with Managed code version as its shown below.








Sunday, 14 October 2012

"Surround with" feature in Visual Studio.

“Surround with” is a very nice features in visual studio IDE. The overall objective of this feature is to surround the code snippets with a set of statement.

Let’s assume that, i have piece of code block and i want to add try-catch surround that code so rather than cut-copy code block “Surround With” feature comes handy.

For that, you need to select piece of code block that you want to surround then right click or simply press shortcut keys: “CTRL+K, S / CTRL +K , CTRL + S”. It will open intellisense from that select any option that you want.

Before “Surround with”

After “Surround with”


Sunday, 7 October 2012

Difference between UNION and UNION ALL in SQL.

Both UNION and UNION ALL concatenate the result of two different SQLs. They differ in the way they handle duplicates.
Ø   UNION performs a DISTINCT on the result set, eliminating any duplicate rows.

Ø   UNION ALL does not remove duplicates, and it therefore faster than UNION.

Note: While using this commands all selected columns need to be of the same data type.
Example: If we have two tables, 1) Employee and 2) Customer

1) Employee table data: 












2) Customer table data:


3) UNION Example (It removes all duplicate records):


4) UNION ALL Example (It just concatenate records, not eliminate duplicates, so it is faster than UNION):


Venn diagram (Visual Representation) of SQL joins.


We all knows SQL joins are used to fetch data from different tables but if for fresher its very easy to understand types of JOINS by visually rather than queries. So today i am going to write article based on that so user can get idea easily.

Ø  LEFT OUTER JOIN: produces a complete set of records from Table A, with the matching records (where available) in Table B. If there is no match, the right side will contain null.
Ø  RIGHT OUTER JOIN: produces a complete set of records from Table B, with the matching records (where available) in Table A. If there is no match, the left side will contain null.
Ø  FULL OUTER JOIN: produces the set of all records in Table A and Table B, with matching records from both sides where available. If there is no match, the missing side will contain null.
Ø  INNER JOIN: produces only the set of records that match in both Table A and Table B.





Saturday, 6 October 2012

How to know tab index of each control in design mode?


When you working with windows application then tab index plays an important role and makes application more effective and professional. But if form contain lots of input controls or maybe you add new controls later on then manage tab index of each and every control is very time consuming and cumbersome. So to know tab index of every control in design mode follow following steps:

   Ø  Open form in design mode.
   Ø  Click on “View” from toolbar à “Tab Order” at bottom.