Friday 4 July 2014

Jquery Datepicker for web application


Hi friends ,

This article is about how to all user jquery Datepicker in your web application.

Consider following example

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">

 <script type="text/javascript">
        $(document).ready(function () {
            $("#textbox1").datepicker({
             
                changeMonth: true,
                changeYear: true,
                yearRange: "-100:+0",
                dateFormat:"dd/mm/yy",
               altFormat: "mm/dd/yy",
               altField: "#hiddenfield1",
               defaultDate: '18/01/1990'

            });

        });
</script>
---------------------------------------------------------------------------------------------
In above example "textbox1" is id of textbox to which you want to apply datepicker.

changeMonth: allows to select monthfrom  dropdown
changeYear:   allows to select year from  dropdown .
dateformat:  format of date in which you want date.
altFormat:  alternate format of date.
altField:     alternate field to which alternate date will be assigned.
defaultDate:  default date selected in datepicker

Note: Remember the links included at top is necessary to get datepicker.
for more details visit  http://jqueryui.com/datepicker/

-----------------------------------------------------------------------------------------

output:

--------------------------------------------------------------------------------------------
Enjoy Scripting..


Thursday 3 July 2014



To Select Row By Id  or All Rows from Table using SQL Server COALESCE() Function.


Hi All,

This Post is about how to use SQL Server COALESCE() function to select Row by Id or All row . Consider following example


SELECT UserId,UserName,UserAddress FROM UserMaster WHERE UserId=coalesce('1,UserId);

In Above example result will be user details whose UserId is 1
---------------------------------------------------------------------------------------------------

Now Consider another example

SELECT UserId,UserName,UserAddress FROM UserMaster WHERE UserId=coalesce(null,UserId);

In Above example  i have passed value ''NULL'  to UserId in COALESCE() function, means when perticular Id is passed to COALESCE() it will return record matching Userid=1 and if null is passes then it will return All Rows. But Remember UserId is a Primary Key.

------------------------------------------------------------------------------------------------------
Now have look at follwing example with stored procedure

CREATE PROCEDURE  msp_select_user
@UserId  Bigint
AS
BEGIN
IF @UserId=0
SET @UserId=Null
END
BEGIN
SELECT UserId,UserName,UserAddress FROM UserMaster WHERE UserId=coalesce(@UserId,UserId);
END


Enjoy SQLing.....