Skip to main content

Posts

Showing posts from November, 2012

How can I get a enum value

int value = (int)Enum.Parse(typeof(CategoriesType), Enum.GetName(typeof(CategoriesType), CategoriesType.Operations));   public enum CategoriesType : int     {         Operations = 1001,         Personnel = 1002,         Safety = 1003     }

Regular Expressions for URL Rewriting

A complete guide to regular expressions is rather beyond the scope of this article. However, important points to remember are that the entire pattern is treated as a regular expression, so always be careful of characters that are “special” characters in regular expressions such as .(DOT stands for any character). . (any character) * (zero of more of the preceding) + (one or more of the preceding) {} (minimum to maximum quantifier) ? (ungreedy modifier) ! (at start of string means “negative pattern”) ^ (start of string, or “negative” if at the start of a range) $ (end of string) [] (match any of contents) - (range if used between square brackets) () (group, backreferenced group) | (alternative, or) \ (the escape character itself) Flags Flags are added to the end of a rewrite rule to tell Apache how to interpret and handle the rule. They are comma-separated, and contained in square brackets. Here’s a list of the flags, with their meanings C (chained with next rule

Upload CSV File And Read Using ASP.NET

--------------------------------------------------------------- CSVReader.cs --------------------------------------------------------------- using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; using System.Text; using System.Collections; public class CSVReader {     //     private Stream objStream;     private StreamReader objReader;     //add name space System.IO.Stream     public CSVReader(Stream filestream) : this(filestream, null) { }     public CSVReader(Stream filestream, Encoding enc)     {         this.objStream = filestream;         //check the Pass Stream whether it is readable or not         if (!filestream.CanRead)         {             return;         }         objReader = (enc != null) ? new StreamReader(filestream, enc) : new StreamReader(filestream);     }     //parse

The Ten Most Asked SQL Server Questions And Their Answers

If you are active in the SQL Server newsgroups and forums as I am, you will notice that the same questions keep popping up all the time. I picked ten of them which I see daily. Since this became a pretty long blogpost I have linked all the questions below to jump to the question itself. 1) Selecting all the values from a table for a particular date 2) Search all columns in all the tables in a database for a specific value 3) Splitting string values 4) Select all rows from one table that don't exist in another table 5) Getting all rows from one table and only the latest from the child table 6) Getting all characters until a specific character 7) Return all rows with NULL values in a column 8) Row values to column (PIVOT) 9) Pad or remove leading zeroes from numbers 10) Concatenate Values From Multiple Rows Into One Column 1 Selecting all the values from a table for a particular date This is a very popular question and people sometimes answer that you need