"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, April 30, 2011

Difference between datetime and smalldatetime datatype in SQL Server 2005

Choosing between datetime and smalldatetime datatype in SQL Server 2005

datetime datatype are used for storing date and time information.

Comparision chart

Data type
Range
Storage/Accuracy
datetime
January 1, 1753, through December 31, 9999
4 Bytes/3.33 milliseconds
smalldatetime
January 1, 1900, through June 6, 2079
2 Bytes/1 minute


datetime is more accurate than smalldatetime datatype.
datetime datatype stores milliseconds data while smalldatetime
datatype doesn't store millisecond data and thus it is less accurate.
But in most cases we don't require such a accurate information, so
in this case you can storing datetime in smalldatetime datatype and saves the extra 2 bytes storage space.
Example: DOJ details of employee doesn't require such a accuracy level so you can use smalldatetime datatype.


Have a nice day... 'N happy Coding :)

Introduction to Global.asax file

Global.asax file is a ASP.Net application file that is optional file.This file contains code for responding to
application-level events raised by ASP.Net based solution.The global.asax file resides in the root directory
of asp.net based application. The Global.asax file is configured so that any direct HTTP request(via URL)is rejected automatically.so user can not download or view its contents.The asp.net framework recognizes automatically any changes that are made to global.asax file.The framework reboot all the application,flushes all state information,closing browsers and restart the apllication domain.
The Global.asax file contain the following events:

1-Application-Init:-This event fired when an application initializes or is first called.It is invoked for all httpApplication object instances.

2-Application_Disposed:  This event fired just before an application destroy.This is ideal location for cleaning previous used resourse.

3-Application_Error:This event fired when an unhandled exception is encountered within the appliction.

4-Application_Start-: This event fired when the first instance of the httpApplication class is created.
     it allows you to create  objects that are accessible by all the HttpAppplicaton instances.

5-Application_End: This event fired when the last instances of HttpApplication class is destroyed.It
  is fired only once during the apllications lifetime.

6-Application_BeginRequest: Fired when application  request is received.It is the first events fired for a request.This is often a page request that a user enters.

7-Application_EndRequest: The last events fired for an appllications request.

8-Session_Start: Fired when a new user visits the appllication web sites.

9-Session_End: Fired when a user's session times out,ends or they leave the application web sites.

10-Application_PreRequestHandlerExecute: This event fired before the ASP.NET page framework begins executing an event handler like pages or web services.

11-Application_PostRequestHandlerExecutes: This events fired when the ASP.NET page framework is finished executing an event handler.

12-Application_PreSendRequestHeaders: This event fired before the ASP.NET page framework sends HTTP headers to a requesting clients.

13-Application_PreSendContent: Fired before the ASP.NET page framework sends content to a requesting client(browser).

14-Application_AcquireRequestState: Fired when the ASP.NET page framework gets the current state(session state)  related to the current page request.

15-Application_RealeaseRequestState: Fired when the ASP.NET page framework completes execution of all events handlers.This result in all state modules to save their current state data.

16-Application_UpdateRequestCache: Fired when the ASP.NET page framework completes handler execution to allow caching modules to store responses to be used to handle subsequent request.

17-Application_AuthenticateRequest: Fired when the security modules has established the dcurrent user's identity as valid.At This piont ,the user's crenditials have been validated.

18-Application_AuthorizeRequest: Fired when the security modules has verified that the user can access resources.


Hope u got It....
Stay Tune...
Have a nice day... 'N happy Coding :)

Wednesday, April 27, 2011

Change HTTP to HTTPS on FACEBOOK

ATTENTION!
While on FB, look at your URL address (the very top box on your screen.) If u
see "http:" or just "www." instead of "https:" then You DO NOT have a
secure session & can be HACKED.
Go to Account -> Account Settings -> Account Security -> click Change.-> Check box (secure browsing), ->click Save. FB has automatically set it on the non-secure setting!


Have a nice day.

Thursday, April 21, 2011

Multiple Control having One event OR selecting alphabet

Hi *.*,
Ha ha both sounds different isit? Actually i'm had a list alphabet (linkbutton) Everyone having same click Event to make may code less and sexy. here its go >>In some situations we may have a requirement to search the records Alphabetic wise. For these type of requirement we have to take 26 alphabets and when we have to generate click events to know which alphabet clicked. Its not a good way to generate 26 button click events. Instead of that we can take Command Name and we will call the same function. And if we make a user control, this control can used many times in our project.

First B'day

Hi *.*,
Today April 21 2011, i completed one successful  year with the help of all my readers.Ask i start as a joke now it's very much serious matter for me.Now every day i have Minimum visitors of 45 (as far Google analytics) and 3,809 visits came from 105 countries/territories in this period and Alexa Traffic Rank 3,555,324.I don't know it's low or hight but I have the same feel that i felt when someone new visited my blog :) .
I really need to say thanks to Pradeep ,Manoj ,Vinay these guys promoted me to start a blog and i did now it's upto this much and  much more it will i feel so...

GA report of 2010-11 period

Stay tune...
Have a nice day... 'N happy Coding :)

Saturday, April 16, 2011

2 redirect on 1event OR Two fires on One event

 Hi *.*,
Yup 2 fires on one event i can say this way too. Here i'm meeting this by JavaScript and by server-side.
Here it's go:

No of records entered in day by a user in sql server.

Hi *.*,
It sounds grt na. :) but actiually its a simple logic.

SELECT COUNT(*) From [Tablebname]where [CreatedDate]=GetDate() and [UserName]=@UserName;

Dense_Rank() function in SQL Server

 Hi *.*,
In my last post i shown Rank function but in rank function repetition will also count as rank.some times this will not meet our requirement, we need the real count.For this SQL has providing another function Dense_Rank().

Rank() function in SQL Server

 Hi *.*,
Understanding Server function makes our code less and more flexible.i believe it strongly.Here is a Another fuction provided by SQL server RANK().

Friday, April 15, 2011

retrieve the RowID after user submit data OR SCOPE_IDENTITY() return the "RowID" from the database on insert

Hi *.*,
Recently I had to write an insert stored procedure and needed to return the ID of the row I was inserting.As i unaware of  SCOPE_IDENTITY() function i was doing some piece of bad coding at their.Getting max id of the table just after the insertion... oooh :( . Last day i was going through asp fourms I came to know abt this. then i plan to make  a try and i achieved the goal too.
Here it goes,

Highlight on RollOver using css and javascript

Hi *.*,
My friends always say my taste in designing is not enough Ha ha But i always try to make best out of that he he.
In my current project i planned to do some thing like Highlight a div on mouse-over.

Tuesday, April 12, 2011

Ajax Model PopUp Extender

Hi *.*,
Before v start building this I prefer u to go through this link.some of common events of this controls are
  • TargetControlID - The ID of the element that activates the modal popup
  • PopupControlID - The ID of the element to display as a modal popup
  • BackgroundCssClass - The CSS class to apply to the background when the modal popup is displayed
  • DropShadow - True to automatically add a drop-shadow to the modal popup
  • OkControlID - The ID of the element that dismisses the modal popup
  • OnOkScript - Script to run when the modal popup is dismissed with the OkControlID
  • CancelControlID - The ID of the element that cancels the modal popup
  • OnCancelScript - Script to run when the modal popup is dismissed with the CancelControlID
  • PopupDragHandleControlID - The ID of the embedded element that contains the popup header/title which will be used as a drag handle
  • X - The X coordinate of the top/left corner of the modal popup (the popup will be centered horizontally if not specified)
  • Y - The Y coordinate of the top/left corner of the modal popup (the popup will be centered vertically if not specified)
  • RepositionMode - The setting that determines if the popup needs to be repositioned when the window is resized or scrolled.
DEMO
 























Friday, April 8, 2011

Showing details on Mouse Over

Hi *.*,
2 I'm showing Some DHTML stuff.Showing details on move over previously i showing image on mouse-over, and also from database too.2day instead of image data. Simple and humble. 

Demo



On HTML


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>

    <script src="http://jquery.bassistance.de/tooltip/jquery.tooltip.js" type="text/javascript"></script>

    <link href="http://jquery.bassistance.de/tooltip/jquery.tooltip.css" rel="stylesheet"
        type="text/css" />

    <script type="text/javascript">
        $(document).ready(function() {
            $(".selector").tooltip({
                track: true,
                delay: 0,
                showURL: false,
                fade: 250,
                bodyHandler: function() {
                    return $($(this).next().html());
                },
                showURL: false
            });
        });
    </script>

    <style type="text/css">
        .tag
        {
            padding: 5px 5px 5px 5px;
            margin: 5px 5px 5px 5px;
            float: left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Repeater ID="dlMinistry" runat="server" >
        <ItemTemplate>
            <div class="tag">
                <a href="#" class="selector">
                    <%#Eval("tag")%></a>
                <div id="tooltip" style="display: none;">
                    <div>
                        <%#Eval("description")%></div>
                </div>
            </div>
        </ItemTemplate>
    </asp:Repeater>
    </form>
</body>
</html>

On Server Side

    protected void Page_Load(object sender, EventArgs e)
    {
        var list = (new[] {
            new { tag = "Simplyasp.net", description = "Welcome To Simplyasp.net" },
            new { tag = "Simplyasp.blogspot.com", description = "Welcome To Simplyasp.net" },
        }).ToList();
        dlMinistry.DataSource = list;
        dlMinistry.DataBind();

    }

I don't think need more documentation over this because it so simple, in-case u need tell me. I will guide u.

Stay Tune...

Have a nice day... 'N happy Coding :)

Thursday, April 7, 2011

Simple javascript Email Validation

Hi *.*,
May some of u think whether my stack got empty or what isit??? ha ha ... I know it's a basic but it's important. On last day i c a post on fourms.asp.net asking for an email validation.he got more than 15 answers...Wow what a luck hand full of options. I gone through one by one.And almost all having a similar feature.Complicated !!!.All are touching the finishing lines but that not a good way , i feel so :( . that makes me this post.
Code:


<head runat="server">
    <title>Simple javascript Email Validation</title>
    <script type="text/javascript">
        function evalue(email) {
           // debugger;
            AtPos = email.indexOf("@")
            StopPos = email.lastIndexOf(".")
            Message = ""

            if (AtPos == -1 || StopPos == -1) {
                Message = "Not a valid email address"
            }

            if (StopPos < AtPos) {
                Message = "Not a valid email address"
            }

            if (StopPos - AtPos == 1) {
                Message = "Not a valid email address"
            }
            if (Message == "")
                return true;
            else
                alert(Message);
    }
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input id="txt" onblur="evalue(this.value)" type="text" />
    </div>
    </form>
</body>
</html>

Its simple and Sexy na, anyway i can feel it (:P
stay tune...

Have a nice day... 'N happy Coding :)

Wednesday, April 6, 2011

Create a Datatable and schema , A new approach

 Hi *.*,
In my last company my senior always use DATATABLE for Binding, i never seen he using DATASET.Difference i seen , by using tables u need to spend more time on coding,On Dataset it finished !!!. But table is fast than set....Any way i used both in my career depending upon needs.Last day my friend introduce me a new approach to Datatables, in one word i'm impressed.Here i'm presenting both.
Old way


    public void _pre()
    {
        try
        {
            DataTable dt = new DataTable("TableName");
            dt.Columns.Add("MyId"typeof(int));
            dt.Columns.Add("Name");
            dt.Columns.Add("Address");
            DataRow dr = new DataRow();
            dr[0] = 1;
            dr[1] = "Arun Aravind";
            dr[2] = "Kollam,Kerala,India";
            dt.Rows.Add(dr);
        }
        catch (Exception)
        {
           
            throw;
        }
    }

New Method




 
    public void _new()
    {
        try
       {
            DataTable dt = new DataTable
            {
                Columns ={
                {"Myid",typeof(int)},
                {"Name"},
                {"Address"}
                }
            };
            dt.Rows.Add(1, "Arun Aravind""Kollam,Kerala,India");
        }
        catch (Exception)
        {
           throw;
        }
    }
 
Now u compare Both new method is so clean and sexy...Isit???

Hope u got it....Stay Tune... 
Have a nice day... 'N happy Coding :)