Posts

Creating XML File Using SQL Server

SELECT ( SELECT 'White' AS Color1, 'Blue' AS Color2, 'Black' AS Color3, 'Light' AS 'Color4/@Special' , 'Green' AS Color4, 'Red' AS Color5 FOR XML PATH('Colors'), TYPE ), ( SELECT 'Apple' AS Fruits1, 'Pineapple' AS Fruits2, 'Grapes' AS Fruits3, 'Melon' AS Fruits4 FOR XML PATH('Fruits'), TYPE ) FOR XML PATH(''), ROOT('SampleXML') /*Out Put*/ <SampleXML>   <Colors>     <Color1>White</Color1>     <Color2>Blue</Color2>     <Color3>Black</Color3>     <Color4 Special="Light">Green</Color4>     <Color5>Red</Color5>   </Colors>   <Fruits>     <Fruits1>Apple</Fruits1>     <Fruits2>Pineapple</Fruits2>     <Fruits3>Grapes</Fruits3>     <Fruits4>Melon</Fruits4>   </Fruits> ...

Delete Duplicate Rows in Sql Server

/* Create Table with 7 entries - 3 are duplicate entries */ CREATE TABLE DuplicateRcordTable (Col1 INT, Col2 INT) INSERT INTO DuplicateRcordTable SELECT 1, 1 UNION ALL SELECT 1, 1 --duplicate UNION ALL SELECT 1, 1 --duplicate UNION ALL SELECT 1, 2 UNION ALL SELECT 1, 2 --duplicate UNION ALL SELECT 1, 3 UNION ALL SELECT 1, 4 SELECT * FROM DuplicateRcordTable /* Delete Duplicate records */ WITH CTE (COl1,Col2, DuplicateCount) AS ( SELECT COl1,Col2, ROW_NUMBER() OVER(PARTITION BY COl1,Col2 ORDER BY Col1) AS DuplicateCount FROM DuplicateRcordTable ) DELETE FROM CTE WHERE DuplicateCount > 1

How to Zip the folder using C#

public static void AddFolderToZip(string sourcePath,string zipFullName)         {             DirectoryInfo CurrentFolder = new DirectoryInfo(sourcePath);             DirectoryInfo RootFolder = CurrentFolder.Parent;             DirectoryInfo[] SubFolders = RootFolder.GetDirectories(CurrentFolder.Name);                                     if (SubFolders.LongLength > 0)             {                 //Add all subfolders to the zip if any         ...

How to Convert Word Document to PDF using C#

  Document wordDocument = null;             string Sourcepath = ConfigurationSettings.AppSettings["SourcePath"];             string DestinationPath = ConfigurationSettings.AppSettings["DestinationPath"];             DirectoryInfo dirInfo = new DirectoryInfo(Sourcepath);             FileInfo[] wordFiles = dirInfo.GetFiles("*.doc");             foreach (FileInfo wordFile in wordFiles)             {                 object paramSourceDocPath = (Object)wordFile.FullName;                 //(Object)wordFile.Na...

On Cascading deletes in SQL Server

CREATE TABLE USERS (     USR_ID int     ,CONSTRAINT [PK_Temp_Users1] PRIMARY KEY CLUSTERED ([USR_ID]) ) CREATE TABLE USER_PHONE (     USR_ID int     ,CONSTRAINT [PK_Temp_Users2] PRIMARY KEY CLUSTERED ([USR_ID]) ) ALTER TABLE [dbo].USER_PHONE  WITH CHECK ADD CONSTRAINT [FK_Temp_UsersPhone_Users] FOREIGN KEY([USR_ID]) REFERENCES [dbo].[Users] ([USR_ID]) ON DELETE CASCADE GO INSERT INTO USERS     SELECT 1 UNION SELECT 2 UNION SELECT 3 INSERT INTO USER_PHONE     SELECT 1 UNION SELECT 2 UNION SELECT 3 SELECT * FROM USERS SELECT * FROM USER_PHONE DELETE USERS WHERE USR_ID=2 SELECT * FROM USER_PHONE DROP TABLE USER_PHONE DROP TABLE USERS

Different types of Time Picker Control examples

http://www.jquery.wisdomplug.com/jquery-plugins/time-picker-jquery-plugin/ http://fgelinas.com/code/timepicker/ http://www.ama3.com/anytime/ http://www.eworldui.net/CustomControls/TimePickerDemo.aspx http://www.asp.net/community/control-gallery/Item.aspx?i=3221 http://www.codeproject.com/KB/selection/cstimepicker.aspx http://jqueryui.com/demos/datepicker/ http://www.codeproject.com/KB/selection/cstimepicker.aspx http://timepicker.codeplex.com/ http://peterblum.com/DES/DemoTimeTextBox.aspx http://jobijoy.blogspot.com/2007/10/time-picker-user-control.html http://jquerybyexample.blogspot.com/2011/12/jquery-timepicker-plugin-demo.html

How to call button event in javascript for cross browsers

function SubmitClick(bt) {        if (navigator.appName.indexOf("Microsoft Internet Explorer") > -1) {         bt.click();         return false;     }     else {         if (bt && typeof (bt.click) == 'undefined') {             bt.click = addClickFunction(bt);             return false;         }         else {             bt.click();             return false;         }         return false;     } } function addClickFunction(bt) { ...