Saturday, October 31, 2015

How to find (get) the Last day of Previous, Current and Next month in Sql server

In this article I am going to explain how to find (get) the Last day of Previous, Current and Next month in Sql server


Implementation:
Use/write the below given quires to get the last day.

Find the last day of previous month:
select CONVERT(varchar,dateadd(d,-(day(getdate())),getdate()),106)'Last Day of Previous Month'

Find the last day of current month:
select CONVERT(varchar,dateadd(d,-(day(dateadd(m,1,getdate()))),dateadd(m,1,getdate())),106)'Last Day of Current Month'

Find the last day of next month:
select CONVERT(varchar,dateadd(d,-

Thursday, October 29, 2015

Simple steps to display data point labels outside a pie Chart in asp.net

In this article I am going to explain how to display the data point labels outside a pie Chart in asp.net

Description:

I am displaying the data in chart control. Chart type is pie. I want to display the data labels outside the pie chart because data values got overlap.

Simple steps to display the data point labels outside a pie Chart in asp.net

Implementation:
To display the outside a pie chart follow the below given steps.

Go to properties section of chart control. In properties section look Chart >>Series >> Misc >>


How to display Microsoft Chart data value on mouse (cursor) hover (tooltip) in asp.net

In this article I am going to explain how to display Microsoft Chart data values on mouse (cursor) hover (tooltip) in asp.net

Description:

I am using the Microsoft chart control to display the data. I want to display the data values on mouse (cursor) hover. I have created a table Tb_Population.

Implementation:
To display the data in tooltip write the below given code.

C# Code:


foreach (Series s in Chart1.Series)
            {
                s.ToolTip = "State: #VALX\nPopulation: #VALY\nPercentage: #PERCENT";
            }

VB.net code:
  For Each s As Series In Chart1.Series
                s.ToolTip = "State: #VALX" & vbLf & "Population: #VALY" & vbLf & "Percentage: #PERCENT"
            Next

Tuesday, October 27, 2015

Top 10 commonly asked Sql server queries in interview

In this article I am going discuss the top 10 commonly asked Sql server queries in interview

1  1.     Find the Highest Salary of Employee
Select MAX(salary) from dbo.Tb_Employee

2    2.    Find the nth number highest salary
In this blow given I have find the second highest salary.
Select Top 1 Salary from(Select distinct top 2 salary from dbo.Tb_Employee order by salary desc) a order by salary asc

3  3.     Find the nth number lowest salary
Using below given query I am finding the second lowest salary.
Select Top 1 Salary from(Select distinct top 2 salary from dbo.Tb_Employee order by salary asc) a order by salary desc

4     4.      Find the duplicate record
Here I am finding the duplicate record (name) exist in table.
select name, count(*)  as duplicate from dbo.Tb_Employee group by name



5   5.      Calculate the Running Total
Select name,phone,ems.salary,(select sum(salary) from dbo.Tb_Employee where id <=ems.id) as Running from dbo.Tb_Employee ems 

Sunday, October 25, 2015

Jquery: shortened the text with Read more link Or Add a read more link using Jquery in asp.net

In this article I am going to explain how to implement read more/less text functionality using Jquery in asp.net application.

Description:

I have post/write a long paragraph/content on website. It not looks good so I want to display the 40 character and after that read more hyperlink link. When user click on it complete paragraph will be display with read less hyperlink button.

Implementation:

Saturday, October 24, 2015

Asp.net: Display data in Chart control from database

In this article I am going to explain how to display/show the data in Asp.net chart control from database

Description:

I have a table Tb_Population and want to display the population state wise in pie chart.

Asp.net: Display data in Chart control from database

Implementation:
Add a webform to project. Drag and drop the chart control from tootlbox to webform.

HTML Markup:

Wednesday, October 21, 2015

Read more and read less text using jquery in asp.net

In this article I am going to explain how to implement read more/less text functionality using Jquery in asp.net application.

Description:

I have post/write a long paragraph/content on website. It not looks good so I want to display the 40 character and after that read more hyperlink link. When user click on it complete paragraph will be display with read less hyperlink button.

Implementation:

Add the below given Jquery in head section of webform/webpage before </head> tag.

Monday, October 19, 2015

Save Youtube video into database and display using Linq

In this article I am going to explain how to save the youtube into database and display it in Gridview using Linq

Description:

I have got a requirement to save the youtube video url into database and display them where user can play the videos.

Implementation:
I have created a table Tb_videos which store the information video tile, description and URL.

Save Youtube video into database and display using Linq

HTML Markup
:

Sunday, October 18, 2015

Asp.net: Autocomplete textbox from Sql server database using Jquery

In this article I am going to explain implement the autocomplete functionality in asp.net application using jquery.

Description:

I have a table Tb_Movie which store the information of movie like name, budget and genre. I want to search the records from table according to name.

Implementation:
Add a webform to project and add the required control from toolbox to webform.

HTML Markup of webform:
<fieldset style="width:450px">
            <legend></legend>
            <table>
                <tr>
                    <td>Movie Name:</td>
                    <td><asp:TextBox ID="txtsearch" runat="server"></asp:TextBox></td>
                </tr>
            </table>
        </fieldset>   

Import the namespaces

Thursday, October 15, 2015

Cascading dropdownlists with linq to sql

In this article I am going to explain how to populate Cascading dropdown list using linq to sql

Description:

I want to populate the Country, State and City dropdownlist.

Implementation:
I have created three tables Tb_Country, Tb_State and Tb_City.

Cascading dropdownlists with linq to sql

HTML Markup of webform:
    <table>
    <tr>
    <td>Select Country:</td>
     <td>  <asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="true"
            onselectedindexchanged="ddlcountry_SelectedIndexChanged">
        </asp:DropDownList></td>
    </tr>
       <tr>
    <td></td>
     <td></td>
    </tr>
     <tr id="state" runat="server">
    <td>Select State:</td>
     <td><asp:DropDownList ID="ddlstate" runat="server" AutoPostBack="true"
            onselectedindexchanged="ddlstate_SelectedIndexChanged">
        </asp:DropDownList></td>
    </tr>
     <tr>
    <td></td>
     <td></td>
    </tr>
     <tr id="city" runat="server">
    <td>Select City:</td>
     <td> <asp:DropDownList ID="ddlcity" runat="server">
        </asp:DropDownList></td>
    </tr>
    </table>

Create object of DBML

Wednesday, October 14, 2015

Play Youtube video using video url in Asp.net

In this article I am going to explain how to play YouTube video using video url in asp.net web application

Description:

I want to play the youtube video in asp.net application. To play the video the simply enter the particular youtube video url.

Implementation:
Add a webform to asp.net application. Add the below given HTML markup to webform.

HTML Markup:
<table>
   <tr>
   <td>Enter Youtube Video URL :</td>
   <td> <asp:TextBox ID="txturl" runat="server" Width="450px"></asp:TextBox></td>
   <td> <asp:Button ID="btnsubmit"
            runat="server" Text="Play"/></td>
   </tr>
   <tr>
   <td colspan="3" id="video" runat="server"></td>
   </tr>
   </table>

On button click write the below given code

Wednesday, October 7, 2015

How to fill Country, State and City dropdown list using linq to sql

In this article I am going to explain how to fill Country, State and City dropdown list using linq to sql

Description:
In the previous article I have explained Youtube autoplay and disable relatedvideos and Asp.net Embed Youtube video

I want to populate the Country, State and City dropdownlist.

Implementation:
I have created three tables Tb_Country, Tb_State and Tb_City.
How to fill Country, State and City dropdown list using linq to sql

HTML Markup of webform:

Friday, October 2, 2015

Youtube: autoplay and disable related videos

In this article today I am going to explain how to set the video autoplay and disable the related video option.

Description:

I have embed a video https://www.youtube.com/watch?v=vOncd4pEErw in asp.net application. I want this video be auto play means when page load it start playing and want to hide the related video option.

Implementation:

To hide the related videos:
To embed the video go to Youtube video URL and scroll down. You see the share option below the video title, click on it.

Youtube: autoplay and disable related videos

There options are available Share, Embed and email. You have to choose the 2nd one (Embed), click on it. 
Youtube: autoplay and disable related videos

Below textbox you see option Show more, click on it and uncheck the “Show suggested videos when the video finishes” option.

Youtube: autoplay and disable related videos


You see an iframe code in textbox. Copy it and paste where you want to display the Youtube Video.

Thursday, October 1, 2015

Asp.net: Embed Youtube video

In this article today I am going to explain how to embed Youtube video in asp.net application

Description:

I want to embed the https://www.youtube.com/watch?v=vOncd4pEErw video in asp.net application.

Implementation:
To embed the video go to Youtube video URL and scroll down. You see the share option below the video title, click on it.

Asp.net: Embed Youtube video

There options are available Share, Embed and email. You have to choose the 2nd one (Embed), click on it. You see an iframe code in textbox. Copy it and paste where you want to display the Youtube Video.
Asp.net: Embed Youtube video


Example: