Posts

Showing posts from 2012

partition by clause

An example using using partition by clause References : http://msdn.microsoft.com/en-us/library/ms189461.aspx The following example shows using the OVER clause with ROW_NUMBER function to display a row number for each row within a partition. The ORDER BY clause specified in the OVER clause orders the rows in each partition by the column Category. The ORDER BY clause in the SELECT statement determines the order in which the entire query result set is returned. Question : I need to get one item each from a category Answer: select* from ( select row_number() over(partition by Category order by ItemName) AS IDv,*  from ( select 'Apple' ItemName,'Fruits'Category UNION ALL select 'Banana' ItemName,'Fruits'Category UNION ALL select 'Turnip' ItemName,'Vegs'Category UNION ALL select 'Tomato' ItemName,'Vegs'Category UNION ALL select 'Eggplant' ItemName,'Vegs'Category ) A )B where b.

Ubuntu Software Center Crashing

Symptom : Ubuntu Software center is unable to open and provide some internal error/unresolved error You would see the following error message E:Encountered a section with no Package: header, E:Problem with MergeList /var/lib/apt/lists/ sg .archive.ubuntu.com_ubuntu_dists_precise_main_binary-i386_Packages, E:The package lists or status file could not be parsed or opened.' Where : sg would be the country, will be us,ca in case of USA or Canada respectively in case of respective countries . You could refer the thread :  http://ubuntuforums.org/showthread.php?t=1750755 Following solved my issues # First delete all of the previously available listings sudo rm /var/lib/apt/lists/* -vf # And then use apt-get to rebuild your package listings sudo apt-get update

Probing element in app.config + Post build event to copy multiple files

Probing is quite good to arrange assemblies in case if you have lots of private libraries referred to your executables and which are there under a probing path mentioned under the probing element in app.config file When I started developing an executable , which demands to split its logic among several dlls and which are part of same solution and are deployed using simple xcopy method I found it quite convenent to use probing path combined with postbuild script under project properties section of the main executable file . Here in my example project, I have a dll project and an executable , which has been refered by the executable project in the same solution The following post-script build script save me from copying the required files into Binaries\Libs folder strcuture under the current selected build method(Release/Debug) . This is quite convenient in case to perform an xcopy of your binaries to the deployment folder. All the unwanted .vshost , pdb,manifest etc  files are

WatiN+CassiniDev project Provide automated testing of your asp.net webforms

WatiN  (pronounced as What-in)   http://watin.org/ WatiN is developed in C# and aims to bring an easy way to automate tests with Internet Explorer and FireFox using .Net Read code project article on WatiN and nUnit http://bit.ly/Mv1RZj CassiniDev project http://cassinidev.codeplex.com/ CassiniDev project is to provide an open platform for developing a robust ASP.Net web server CassiniDev is packaged as a standalone WinForms GUI application, a console application and library assembly suitable for self hosting and in automated testing scenarios including continuous integration and as a 100% compatible drop-in replacement for the Visual Studio 2008/2010 development server. Combining CassiniDev project  +  WatiN  + VisualStudioTestProject OR nUnit + your asp.net web application project = Automated asp.net webform testing without providing a moke object for your asp.net page I have made one sample application which can be downloaded by accessing URL  http://bit.ly/MvcvPS  (Goo

SQL Statements

--1) Reseed Indentity column --drop table TABLE_NAME if  exists (select * from sys.objects where name='TABLE_NAME') drop table TABLE_NAME create table TABLE_NAME (ID int primary key identity (1,1),Increment int ) insert into TABLE_NAME (Increment ) values(1) insert into TABLE_NAME (Increment ) values(1) insert into TABLE_NAME (Increment ) values(1) insert into TABLE_NAME (Increment ) values(1) select 'Max of id is ' ,max(id) from TABLE_NAME delete from TABLE_NAME select 'Max of id after delete  ', isnull(max(id),0) from TABLE_NAME insert into TABLE_NAME (Increment ) values(1) insert into TABLE_NAME (Increment ) values(1) insert into TABLE_NAME (Increment ) values(1) insert into TABLE_NAME (Increment ) values(1) select 'Max of id after delete  insert', max(id) from TABLE_NAME --Reseed the Identity column with with one, so that the autoincremented delete  TABLE_NAME DBCC CHECKIDENT (TABLE_NAME, RESEED, 1) insert into TABLE_NA

List of useful tools(Must have tools/Application)

 Snoop WPF (allows you to spy/browse the visual tree and change properties of a WPF UI) http://bit.ly/HgOHYc 7zip ( Zipping utility that supports number of different compression and extraction format 7zip,.tar,.zip,.rar,.bz etc:.) http://bit.ly/HQG6RC Free download manager(Accelerate downloading of files by using sliced download and support built-in bit-torrent protocol which can be enabled/disabled, once it is disables we cannot download using .torrent files) http://bit.ly/HgQ0ql Winmerge Compare and merge plain text files or directories . read more here  http://winmerge.org/ Libere office, replacement for MS Office  http://www.libreoffice.org/download/ Unstopcopy (Copies files from a source , can be useful if you would like to read corrupted files from your old VCD/CD/DVD)  http://bit.ly/HgRgti Sysinternals Suit (Complete set of tools required to master windows)  http://technet.microsoft.com/en-us/sysinternals/bb842062 Free English dictionary , select the word and

.NET 4.5 Beta- WPF Changes

The new Ribbon control, which enables you to implement a ribbon user interface that hosts a Quick Access Toolbar, Application Menu, and tabs. The new INotifyDataErrorInfo interface, which supports synchronous and asynchronous data validation. New features for the VirtualizingPanel and Dispatcher classes. Improved performance when displaying large sets of grouped data, and by accessing collections on non-UI threads. Data binding to static properties, data binding to custom types that implement the ICustomTypeProvider interface, and retrieval of data binding information from a binding expression. Repositioning of data as the values change (live shaping). Ability to check whether the data context for an item container is disconnected. Ability to set the amount of time that should elapse between property changes and data source updates. Improved support for implementing weak event patterns. Also, events can now accept markup extensions. http://msdn.microsoft.com/en-us/library/bb613588(v=vs

How to find out to which table the column name belongs to ?

How to find out to which table the column name belongs to ? Ans: SELECT TABLE_NAME=SYSOBJECTS.NAME, COLUMN_NAME=SYSCOLUMNS.NAME, DATATYPE=SYSTYPES.NAME, LENGTH=SYSCOLUMNS.LENGTH FROM SYSOBJECTS JOIN SYSCOLUMNS ON SYSOBJECTS.ID = SYSCOLUMNS.ID JOIN SYSTYPES ON SYSCOLUMNS.XTYPE=SYSTYPES.XTYPE WHERE SYSOBJECTS.XTYPE=’U’ AND SYSCOLUMNS.NAME LIKE (‘COLUMNAME2FIND%’) ORDER BY SYSOBJECTS.NAME,SYSCOLUMNS.COLID --keep posting

Map more than one sitemap in asp.net webform

How to map more than one  sitemap in same asp.net webforms application ? If there are  multiple sitemap in an asp.net application eg: for your administrator you need to show entirely different set of menu compared to normal user . After adding following entry in web.config will help in using multiple sitemap, you can have 2 different sitemap files named AppDefaultMap.sitemap and AdminSitemap.sitemap (remember by default we can have only one web.sitemap file in our project)                         name="AppDefaultSiteMap"           type="System.Web.XmlSiteMapProvider"           siteMapFile="~/Application.sitemap" />                    name="AdminSitemap"           type="System.Web.XmlSiteMapProvider"           siteMapFile="~/AdminMenu.sitemap" /> --keep posting.

Swap mouse button

Code to swap the mouse button's action using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace MouseSwap /// Summary description for Class1. /// class Class1 { [DllImport("user32.dll")] static extern bool SwapMouseButton(bool fSwap); /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { bool b; using(System.Threading.Mutex m=new System.Threading.Mutex(true, "ajai_myname_is Different _guid",out b)) { if(!b) { MessageBox.Show("An Instance Already Runnig!","Error", MessageBoxButtons.OK,MessageBoxIcon.Stop); return; }    Console.WriteLine("Swapping Primary Button From {0}",System.Windows.Forms. SystemInformation.MouseButtonsSwapped?"Right to Left":"Left to Right");    SwapMouseButton(!System.Windows.Forms.SystemInformation. MouseButtonsSwapped);    Console.WriteLine("Swapped\n\a\a \t \n Developed by Ajai NP"); }} } } --keep posi