Friday, June 26, 2009

How to get Duplicate records in a Table

Last day, I seamlessly entered into a situation where I want to list out all the repeating/duplicate records from a table. Though it sounds simple, its bit a tricky approach.

As a small example: consider a table say RepeatTest having 2 fields: Id and Url. To figure out the repeating Url records, you can write the query as:

   1:  
   2: SELECT Url, count(Url) FROM RepeatTest
   3:     GROUP BY Url
   4:         HAVING (COUNT(Url)>1)
   5:  

Sometimes you may also jump into sudden simple queries, as what I’d jumped into.

Update: This simple question was asked for the Huwaei International's written exam, held at Bangalore on July 2009.

Thursday, June 25, 2009

Automatic Implemented Properties in .NET 3.5

One of the cool feature that I like in .NET 3.5 is the automatic implementation of Properties in .NET 3.5. Here is a sample:

   1:  
   2: private string _name
   3:  
   4: public string Name
   5: {
   6:     get
   7:     {
   8:         return _name;
   9:     }
  10:     set
  11:     {
  12:         _name = value;
  13:     }
  14: }

Can be re-written as:

   1:  
   2: public string Name {get; set;}
   3:  

Saturday, June 20, 2009

Operation aborted in IE8

Dear Readers/Visitors, as you might know you may receive an “Operation Aborted” error message, when visiting my blog using Internet Explorer. Honestly, I don't know what had happened. How sad. (I’m an IE Lover…!!!).

I’ve posted the issue in IE MSDN Forum. Though they helped, but was not solved completely. Also, they have provided some troubleshooting methods to solve the issue. If you are experiencing the same problem of “Operation Aborted” exception, then have a look at the discussion here.

Thanks.

Update: I think the problem is solved now. I'm not getting the error message. What about you guys?

Saturday, May 9, 2009

jQuery quick notes

Here is some quick notes while handling jQuery.

   1: // Locates all elements with type=Text
   2: $("input[type=text]")
   3:  
   4: // Selects all <div> element with 'title' attributes
   5: // whose value begins with 'my'
   6: $("div[title^=my]")
   7:  
   8: // Locates all links that refers PDF
   9: $("a[href$=.pdf]")
  10:  
  11: // Locates anchor elements having the value
  12: // someurl.com anywhere in the 'href' attribute
  13: $("a[href*=someurl.com]")
  14:  
  15: // Locates all the achor tags
  16: // coming inside a li tag
  17: $("li:has(a)")
  18:  
  19: // Locates anchor(a) tags inside a paragraph(p) tag
  20: // where anchor-tag having a cssClass="someCssClass"
  21: $("p a.someCssClass")
  22:  
  23: // Matches all anchor(a) tags
  24: $("a")
  25:  
  26: // Matches element having an id=someId
  27: $("a#someId")
  28:  
  29: // Matches all elements having a CssClass=someCssClass
  30: $(".someCssClass")
  31:  
  32: // Locates anchor(a) tag with Id=someId and cssClass=someCssClass
  33: $("a.someId.someCssClass")

Reference: Manning’s jQuery in Action.


I must say, it’s a must read book.

Thanks.

Friday, May 8, 2009

No jQuery intellisense in Visual Studio Workaround

If you are using jQuery 1.3.2 in Visual Studio 2008 or Visual Web Developer 2008 (SP1), you may come across scenario where you wont get the jQuery intellisense support, even if you add jquery-1.3.2-vsdoc2.js file to the aspx page.

The workaround is simple. All you’ve to do, is to rename the jquery-1.3.2-vsdoc2.js to jquery-1.3.2-vsdoc.js.

It looks like:

   1: <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>
   2: <script src="Scripts/jquery-1.3.2-vsdoc.js" type="text/javascript"></script>

Note: For making VS/VWD to support jQuery intellisense, you’ve to apply a patch from the VS Development team & can be downloaded from here.

 
Best viewed in Internet Explorer 8.