Tuesday, July 8, 2014

Difference Between the HAVING and WHERE Clauses in a SQL Query

Hello friends ,
Today while querying for some condition , i was looking for where and having clauses.

Please read the below difference , it may help you in future

Though the HAVING clause specifies a condition that is similar to the purpose of a WHERE clause, the two clauses are not interchangeable. Listed below are some differences to help distinguish between the two:

    The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause.
    The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping.
    The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions.



Where Clause:
1.Where Clause can be used other than Select statement also
2.Where applies to each and single row
3.In where clause the data that fetched from memory according
to condition
4.Where is used before GROUP BY clause
Ex:Using Condition for the data in the memory.

Having Clause:
1.Having is used only with the SELECT statement.
2.Having applies to summarized rows (summarized with GROUP BY)
3.In having the completed data firstly fetched and then separated according to condition.
4.HAVING clause is used to impose condition on GROUP Function and is used after GROUP BY clause in the query
Ex: when using the avg function and then filter the data like ava(Sales)>0




Hope it will help you in some way....

Enjoy the day with Lots of smile and Happiness.....

Monday, July 7, 2014

advanced search in Gmail

Now when we see about search in Gmail , lets see about advance search and shortcuts

Using advanced search
Advanced search operators are query words or symbols that perform special actions in Gmail search. These operators allow you to find what you're looking for quickly and accurately. They can also be used to set up filters so you can organize your inbox automatically. Some of the most useful operators are listed below.
You can also refine your search by clicking the arrow in the search box.

Operator
Definition
Example(s)
from:
Used to specify the sender
Example: from:amy
Meaning: Messages from Amy
to:
Used to specify a recipient
Example: to:david
Meaning: All messages that were sent to David (by you or someone else)
subject:
Search for words in the subject line
Example: subject:dinner
Meaning: Messages that have the word "dinner" in the subject
OR
Search for messages matching term A or term B*
*OR must be in all caps
Example: from:amy OR from:david
Meaning: Messages from Amy or from David
-
(hyphen)
Used to exclude messages from your search
Example: dinner -movie
Meaning: Messages that contain the word "dinner" but do not contain the word "movie"
label:
Search for messages by label*
*There isn't a search operator for unlabeled messages
Example: from:amy label:friends
Meaning: Messages from Amy that have the label "friends"
Example: from:david label:my-family
Meaning: Messages from David that have the label "My Family"
has:attachment
Search for messages with an attachment
Example: from:david has:attachment
Meaning: Messages from David that have an attachment
list:
Search for messages on mailing lists
Example: list:info@example.com
Meaning: Messages with the words info@example.com in the headers, sent to or from this list
filename:
Search for an attachment by name or type
Example: filename:physicshomework.txt
Meaning: Messages with an attachment named "physicshomework.txt"
Example: label:work filename:pdf
Meaning: Messages labeled "work" that also have a PDF file as an attachment
" "
(quotes)
Used to search for an exact phrase*
*Capitalization isn't taken into consideration
Example: "i'm feeling lucky"
Meaning: Messages containing the phrase "i'm feeling lucky" or "I'm feeling lucky"
Example: subject:"dinner and a movie"
Meaning: Messages containing the phrase "dinner and a movie" in the subject
( )
Used to group words
Used to specify terms that shouldn't be excluded
Example: from:amy (dinner OR movie)
Meaning: Messages from Amy that contain either the word "dinner" or the word "movie"
Example: subject:(dinner movie)
Meaning: Messages in which the subject contains both the word "dinner" and the word "movie"
in:anywhere
Search for messages anywhere in Gmail*
*Messages in Spam and Trash are excluded from searches by default
Example: in:anywhere movie
Meaning: Messages in All Mail, Spam, and Trash that contain the word "movie"
in:inbox
in:trash
in:spam
Search for messages in Inbox, Trash, or Spam
Example: in:trash from:amy
Meaning: Messages from Amy that are in Trash
is:important
label:important
Search within messages that Priority Inbox considers important.
Example: is:important from:janet
Meaning: Messages from Janet that were marked as important by Priority Inbox
is:starred
is:unread
is:read
Search for messages that are starred, unread or read
Example: is:read is:starred from:David
Meaning: Messages from David that have been read and are marked with a star
has:yellow-star
has:red-star
has:orange-star
has:green-star
has:blue-star
has:purple-star
has:red-bang
has:orange-guillemet
has:yellow-bang
has:green-check
has:blue-info
has:purple-question
Search for messages with a particular star
Example: has:purple-star from:David
Meaning: Messages from David that are marked with a purple star
cc:
bcc:
Used to specify recipients in the cc: or bcc: fields*
*Search on bcc: cannot retrieve messages on which you were blind carbon copied
Example: cc:david
Meaning: Messages that were cc-ed to David
after:
before:
Search for messages sent during a certain period of time*
*Dates must be in yyyy/mm/dd format.
Example: after:2004/04/16 before:2004/04/18
Meaning: Messages sent between April 16, 2004 and April 18, 2004.*
*More precisely: Messages sent after 12:00 AM (or 00:00) April 16, 2004 and before April 18, 2004.
is:chat
Search for chat messages
Example: is:chat monkey
Meaning: Any chat message including the word "monkey".
deliveredto:
Search for messages within a particular email address in the Delivered-To line of the message header
Example: deliveredto:username@gmail.com
Meaning: Any message with username@gmail.com in the Delivered-To: field of the message header (which can help you find messages forwarded from another account or ones sent to an alias).



Hope it will make your search simple and easier...
 Enjoy the day with Lots of smile and Happiness.....


Search In Gmail

Hello Friends,
Today morning i was searching for perticular mail in my Gmail, and I get lot of difficulties in that so thought to search for it and found very good article on that
sharing with you the same..

Search, Don't Sort?
Maybe you, like me, are good at collecting emails. The Archive button in Gmail is really good for that.
Fortunately, most of these archived emails are never to be seen or searched again. But others we need to get back to later.
Of course, you have discovered and tested the big Search Mail field that runs across Gmail's top border. Usually, it works. Sometimes, however, the number of emails returned is just too large. Maybe add a further term or the name of the sender?
Yes, but do it smartly. Using some clever search operators, you can narrow your search significantly and precisely. You can search in the Subject line only, for example, or combine that with a date range, a particular sender, and exclude all messages with attachments.
Search Mail in Gmail
To find messages in Gmail:
  • Type search terms in the Search Mail field.
    • You can go to Search Mail quickly by pressing /.
Use the following operators:
  • subject: - Search the Subject line.
    Example: "subject:bahamas" finds all messages with "bahamas" in the Subject.
  • from: - Search Gmail for sender name and email address. Partial addresses are okay.
    Example: "from:heinz" finds all messages from "heinz@about.com", but also all messages from "your.heinz@tqn.com".
  • to: - Search the To line for names and addresses.
    Example: "to:quertyuiop@gmail.com" finds all messages sent directly (not via Cc: or Bcc:) to quertyuiop@gmail.com.
  • cc: - Search recipients in the Cc field.
    Example: "cc:quertyuiop@gmail.com" finds all messages that were sent to quertyuiop@gmail.com as a carbon copy.
  • bcc: - Search Gmail for addresses and names in the Bcc field. Note this only works with emails you sent to Bcc recipients from Gmail.
    Example: "bcc:heinz" finds all messages that you sent with, for example, "hein@example.com" in the Bcc field.
  • label: - Search Gmail for messages assigned a label. (Replace whitespace characters in label names with hyphens.)
    Example: "label:toodoo-doll" finds all messages labeled "toodoo doll".
  • is:starred - Search Gmail for messages that are starred.
  • With Superstars enabled:
    • has:yellow-star - Search Gmail for messages with a yellow star.
    • has:red-star - Search Gmail for messages with a red star.
    • has:orange-star - Search Gmail for messages with an orange star.
    • has:green-star - Search Gmail for messages with a green star.
    • has:blue-star - Search Gmail for messages with a blue star.
    • has:purple-star - Search Gmail for messages with a purple star.
    • has:yellow-bang - Search Gmail for messages with a yellow exclamation mark.
    • has:red-bang - Search Gmail for messages with a red exclamation mark.
    • has:purple-question - Search Gmail for messages with a purple question mark.
    • has:orange-guillemet - Search Gmail for messages with two orange forward arrows.
    • has:blue-info - Search Gmail for messages with a blue i.
  • is:unread - Search Gmail for new and unread messages.
  • is:read - Search Gmail for messages that have already been opened.
  • is:important - Search Gmail for messages that are marked important for Priority Inbox.
  • has:attachment - Search Gmail for messages that have files attached to them.
  • filename: - Search within file names of attachments. You can also search for file name extensions to restrict your search to certain file types.
    Example: "filename:.doc" finds all messages with word processing attachments.
  • is:buzz - Search Gmail for Google Buzz posts.
  • is:chat - Search Gmail for chat logs.
  • lang: - Search Gmail for messages in a particular language. (Specify the language in English; "Chinese" works, but "中文", "Putonghua" or "Mandarin" do not, for example.)
    Example: "lang:French" returns all emails that contain at least un peu de Français.
  • in: - Search in a standard "folder". You can search in Drafts, Inbox, Chats, Sent, Spam, Trash and anywhere (for everything, including Spam and Trash).
    Example: "in:drafts" finds all messages in your Drafts folder.
  • after: - Search for messages sent on or after a date. The date must be given in YYYY/MM/DD format.
    Example: "after:2005/05/05" finds all messages sent or received on or after (i.e. including) May 5, 2005.
  • before: - Search Gmail for messages sent before a date.
    Example: "before:2005/05/05" finds all messages sent or received on May 4, 2005 and earlier.
  • rfc822msgid: - Search for the message with the — just about certainly unique — message ID. Gmail will not search for messages that refer to the message ID (replies, for example). Example: "rfc822msgid:wW28fb6uf@mail.example.com" finds the message with "wW28fb6uf@mail.example.com" in the "Message-ID:" header field.
Operators and search terms can be combined with the following modifiers:
  • By default, Gmail combines terms with (an invisible) "AND".
    Examples: "shepherd macaroni" finds all messages that contain both "shepherd" and "macaroni"; "before:2005/05/05 AND after:2005/05/04" finds all messages sent or received on May 4, 2005.
  • "" - Search for a phrase. Case does not matter.
    Examples: "shepherd's macaroni" finds all messages containing the phrase "shepherd's macaroni"; 'subject:"shepherd's macaroni' finds all messages that have "shepherd's macaroni" in the Subject field.
  • OR - Search Gmail for messages containing at least one of two terms or expressions.
    Examples: "shepherd OR macaroni" finds messages that contain either "shepherd" or "macaroni" or both; "from:heinz or label:toodoo-doll" finds messages that either come from a sender that contains "email.guide" or appear under the label "toodoo doll".
  • - - Search Gmail for messages that do not contain a term or expression.
    Examples: "-macaroni" finds all messages that do not contain the word "macaroni"; "shepherd -macaroni" finds all messages that contain the word "shepherd" but not "macaroni"; 'subject:"shepherd's macaroni" -from:heinz' finds all messages with "shepherd's macaroni" in the subject that were not sent from an email address or name containing "heinz".
  • () - Group search terms or expressions.
    Examples: "subject:(shepherd macaroni)" finds messages that have both "shepherd" and "macaroni" somewhere in the Subject line (but not necessarily as a phrase); "from:heinz (subject:(shepherd OR macaroni) OR label:toodoo-doll)" finds all messages from a sender who has "email.guide" in their name that either have "shepherd" or "macaroni" (or both) in the Subject line or appear under the label "toodoo doll".


Hope it will save your time in searching :)

Till the time

Enjoy the day with Lots of smile and Happiness.....

Difference between Array and ArrayList

Hello Friends,
This time also I am writing on  difference between ..
Today we will try to see some difference between Array and ArrayList

Array is the collection of values of the same data type
>the variables in an array is called array elements
>Array is a reference type data type
>The array
 structure in System's Memory


Array list is a class .
>when you want to access the elements of an array through its
index value location in an array,use an ArrayList.
>The use of the arraylist is an alternative to the use of th array.
>The Methods Of ArrayList class are
1)Add
2)Remove
3)Clear
4)Insert
5)TrimToSize
6)Sort
7)Reverse

Array mainly used to save variables of same data type.But array list is used to store and retrieve the variables of different data type.

You cant resize an array but you can do it with array list.

Array:-
Provides methods for creating,
 manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.

array list-
Implements the
 System.Collections.IList interface using an array whose size is dynamically increased as required.

IList InterFace
Represents a non-generic
 collection of objects that can be individually accessed by index.


Array is used for fixed size
while array list is dynamically increasing at run time that is size of array list increasing as per requirement.


Array is value Type And of fixed size, and can handle only one Type.

Array list is Reff Type. And Can be appended or restricted at any moment.


Hope it will help you somewhere.

Till the time 

Enjoy the day with Lots of smile and Happiness.....

Difference between App_Code and App_Data

Hello friends ,
many time one question comes in my mind ,what is the Difference between App_Code and App_Data.
and for the same I googled a lot and finally summarized this information in a very simple words.

Please check the below difference ..

Difference between App_Code and App_Data

App_Code
------
This will be used to hold the .cs files within a application.
These cs files will be available for the entire application.This folder can contain any number of files.
They may be .vb or .cs files.The files available in the folder will be compiled in to dlls dynamically.
U can have the file belong to a single programming language like either .vb or .cs.If u want to have more then u have to
configure the web.config file.

This is similaar to the bin folder except this can hold the source code.This folder can contain subfolders also.
Although this can contain many folders all teh files inside this folder will be compiled as a singleassembly.


App_Data
--------
This folder will be used for adding the databases to the application.The database files like .mdf,.mdb,xml files can
also be added to this folder.This way the database files can be added to the website.



I try my best to explain in a very simple manner.

If you have any issue ,please let me know.


Till the  time

Enjoy the day with Lots of smile and Happiness.....

Simple DataSet Example with Code

Hello again :)

This time we will see some code for DataSet.
Here we will see how to use Dataset and show the fetched data in GridView.

Code is as below

DataSet dsMainCatagory = new DataSet();
                string query = "select * from tblMainCategoryMaster where Enable=1 and MainCategoryName like'" + txtSearchMainCatagory.Text+ "%" + "'";

                SqlDataAdapter daa = new SqlDataAdapter(query ,global.cn);

                daa.Fill(dsMainCatagory);


                DataView dvw = dsMainCatagory.Tables[0].DefaultView;

                dgvallmaincat.DataSource = dvw;

                dgvallmaincat.Show();


Hope it will save your time in future.

I have post these information regarding DataSet and DataReader because they are mostly asked in Interview.


Enjoy the day with Lots of smile and Happiness.....

Simple DataReader Example with Code

Hello Friends, Now a days we mostly handles queries inline.
Here's a simple code to fetch data using DataReader and showing it into Combobox.

SqlCommand cmd = new SqlCommand("select MainCategoryId from    tblMainCategoryMaster where Enable=1", global.cn);
global.cn.Open();
SqlDataReader dr1 = cmd.ExecuteReader();
cmbMainCategoryId.Items.Add("--Select--");
while (dr1.Read())
{
     cmbMainCategoryId.Items.Add(dr1["MainCategoryId"].ToString());
}

global.cn.Close();


Hope it will save your time in future.
PS : It is mostly helpful in interviews :)

Enjoy the day with Lots of smile and Happiness.....

Tuesday, July 1, 2014

Code to Check for file exist or not and If exist then delete and save

if (!Directory.Exists(Server.MapPath(@"ProjectPoster\\ProjectFile\\")))
{
Directory.CreateDirectory(Server.MapPath(@"ProjectPoster\\ProjectFile\\"));
}
fileExist = "~/ProjectPoster/ProjectFile/" + strFileName;
if (File.Exists(Server.MapPath(fileExist)))
{
File.Delete(Server.MapPath(fileExist));
}



Enjoy the day with Lots of smile and Happiness.....

Code of creating and clearing cookie for 'Remember Me' Check-box At Login page !!!



We all do coding for remembering the User-name and Password of user by creating cookie ( If user checks 'Remember Me' check-box while Login) or sometime it may happens that we forget to write a code for that functionality or even if we write a code, it doesn't work because of some mistakes. And we never bother to clear that cookie when next time that user log-outs and unchecked the 'Remember Me' check-box and Login again.

Please find the below code which we should use at Login page to create and clear cookie:
protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                //Uncheck the 'Remember Me' checkbox.
                RemMeCheckBox.Checked = false;

                //Check if cookie contains data.
                HttpCookie cookie = Request.Cookies["TNCredentialCookieOfAdmin"];
                if (cookie != null)
                {
                    //If cookie is not null and contains data, display data to user(as he wished to remember his Username and password.)
                    string username = cookie.Values["Username"].ToString();
                    string password = cookie.Values["Password"].ToString();
                    if (username != null)
                    {
                        txtUserName.Text = username;
                    }
                    if (password != null)
                    {
                        txtPassword.Attributes.Add("value", password);
                    }
                    //Check the 'Remember Me' checkbox.
                    RemMeCheckBox.Checked = true;
                }
                //your other code
                .
                .
                .
            }
        }
        catch (Exception ex)
        { }
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {          
            //your other code
            .
            .
            .
            //code for 'Remember Me' checkbox
            if (RemMeCheckBox.Checked == true)
            {
                //If 'Remember Me' checkbox is checked, create a cookie which will maintain Users Username and Password.
                HttpCookie createCookie = new HttpCookie("TNCredentialCookieOfAdmin");
                createCookie.Values["Username"] = txtUserName.Text.ToString();
                createCookie.Values["Password"] = txtPassword.Text.ToString();
                Response.Cookies.Add(createCookie);
            }
            else
            {
                //If 'Remember Me' checkbox is not checked, clear the cookie.
                Response.Cookies["TNCredentialCookieOfAdmin"].Expires = DateTime.Now;
            }
        }
        catch (Exception ex)
        { }
    }