Skip to main content

Posts

How to Remove duplicate records - Sql-server 2005

Query to remove duplicate records, in this query please add all the columns in GROUP BY clause that are duplicate, it is based on primary key DELETE from TableName WHERE CoumnName1 + CoumnName2 + CoumnName3 IN (select CoumnName1 + CoumnName2 + CoumnName3         FROM TableName         group by CoumnName1 , CoumnName2 ,CoumnName3         having Count(ID)>1) AND ID NOT IN (select MAX(ID) from TableName         WHERE CoumnName1 + CoumnName2 + CoumnName3         IN (select CoumnName1 + CoumnName2 + CoumnName3                 FROM TableName                 group by CoumnName1 , CoumnName2 ,CoumnName3                 having Count(ID)>1)  ...

How to DownLoad a File in ASP.NET ?

To DownLoad a file:- 1. Add a link to page, Like this :-                <a href="Download.ashx?FileName=file.pdf&FilePath=DownLoad/">Download Standing Order Mandate</a >           Where file.pdf = file to download                      DownLoad = Folder name where the file placed at server. 2. Then  Add a Generic Handler to the website/project with the name Download.ashx and add the following code:    public void ProcessRequest(HttpContext context)     {         if (context.Request.QueryString["FileName"] != null && context.Request.QueryString["FilePath"] != null)         {           ...

Date Format, C#

Date Fromat Output dd-MMM-yyyy 15-Feb-2010 dd-MM-yyyy 15-02-2010 dd-MMM-yyyy hh:mm:ss 15-Feb-2010 11:25:56 dd-MMM-yyyy hh:mm tt 15-Feb-2010 11:25 AM dd-MMM-yy 15-Feb-10 MMM dd, yyyy Feb 15, 2010 MMMM dd, yyyy April 15, 2010 Example: DateTime objDt = DateTime.Now; objDt.ToString("dd-MMM-YYYY") = 15-Feb-2010

Trim a string to a specified length, C#

Trim a string to a length, Here         public  string TrimString(string strValue,int Count)         {                        if (strValue.Length > Count)             {                 strValue = strValue.Substring(0, Count - 1) + "..";             }             return strValue;         }

Generate an alphanumeric Random Code, C#

        To generate an alphanumeric Random code          ///         /// Public static function Generate Random Code         /// generate the random code         /// Created By:   Munesh         /// Created Date: Feb 10, 2010         ///         /// string          public static string GenerateRandomCode()         {             int _minLength = 6, _maxLength = 6;             string _charsLCase = "abcdefgijkmnopqrstwxyz";             string _charsUC...

Resize image and save without saving it to temporary file, C#

Upload an image after resizing to specific size without saving it to temporary file.       ResizeImageAndSave(fileImage.PostedFile.InputStream, Width, Height, FileName);         ///         /// Resize image of Weight X Height and save         ///         public static void ResizeImageAndSave(Stream fs, int intW, int intH, string FileName)         {             System.Drawing.Image objImg = Bitmap.FromStream(fs);             int intImgH = objImg.Height;             int intImgW = objImg.Width;             double R = ((double)intImgW / (double)intImgH);  ...