3 Mar 2016

Insert script for INDIA States and Districts SQL

  // Latest List Updated here



CREATE TABLE [dbo].[tbl_Countries](
       [CountryID] [int] IDENTITY(1,1) NOT NULL,
       [CountryName] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED
(
       [CountryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tbl_Districts]     ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tbl_Districts](
       [DistrictID] [int] IDENTITY(1,1) NOT NULL,
       [StateID] [int] NULL,
       [DistrictName] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED
(
       [DistrictID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tbl_States]     ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tbl_States](
       [StateID] [int] IDENTITY(1,1) NOT NULL,
       [CountryID] [int] NULL,
       [StateName] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED
(
       [StateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET IDENTITY_INSERT [dbo].[tbl_Countries] ON

GO
INSERT [dbo].[tbl_Countries] ([CountryID], [CountryName]) VALUES (1, N'India')
GO
SET IDENTITY_INSERT [dbo].[tbl_Countries] OFF
GO
SET IDENTITY_INSERT [dbo].[tbl_Districts] ON

GO
INSERT [dbo].[tbl_Districts] ([DistrictID], [StateID], [DistrictName]) VALUES (1, 2, N'Visakhapatnam')
GO
INSERT [dbo].[tbl_Districts] ([DistrictID], [StateID], [DistrictName]) VALUES (2, 2, N'Vijayawada')

GO
SET IDENTITY_INSERT [dbo].[tbl_Districts] OFF
GO
SET IDENTITY_INSERT [dbo].[tbl_States] ON

GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (1, 1, N'ANDAMAN AND NICOBAR ISLANDS')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (2, 1, N'ANDHRA PRADESH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (3, 1, N'ARUNACHAL PRADESH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (4, 1, N'ASSAM')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (5, 1, N'BIHAR')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (6, 1, N'CHATTISGARH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (7, 1, N'CHANDIGARH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (8, 1, N'DAMAN AND DIU')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (9, 1, N'DELHI')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (10, 1, N'DADRA AND NAGAR HAVELI')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (11, 1, N'GOA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (12, 1, N'GUJARAT')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (13, 1, N'HIMACHAL PRADESH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (14, 1, N'HARYANA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (15, 1, N'JAMMU AND KASHMIR')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (16, 1, N'JHARKHAND')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (17, 1, N'KERALA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (18, 1, N'KARNATAKA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (19, 1, N'LAKSHADWEEP')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (20, 1, N'MEGHALAYA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (21, 1, N'MAHARASHTRA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (22, 1, N'MANIPUR')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (23, 1, N'MADHYA PRADESH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (24, 1, N'MIZORAM')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (25, 1, N'NAGALAND')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (26, 1, N'ORISSA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (27, 1, N'PUNJAB')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (28, 1, N'PONDICHERRY')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (29, 1, N'RAJASTHAN')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (30, 1, N'SIKKIM')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (31, 1, N'TAMIL NADU')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (32, 1, N'TRIPURA')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (33, 1, N'UTTARAKHAND')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (34, 1, N'UTTAR PRADESH')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (35, 1, N'WEST BENGAL')
GO
INSERT [dbo].[tbl_States] ([StateID], [CountryID], [StateName]) VALUES (36, 1, N'Telangana')
GO

SET IDENTITY_INSERT [dbo].[tbl_States] OFF
GO




youtube video thumbnail generator asp.net c#

here i explained how to add  youtube video thumbnail without uploading image

.CS code 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Here we are binding static urls, you can also bind from database table
            DataTable dt = new DataTable();
            dt.Columns.Add("YoutubeVideoURL");
            DataRow dr= dt.NewRow();
            DataRow dr1= dt.NewRow();
            dr["YoutubeVideoURL"] = "https://www.youtube.com/watch?v=testis";
            dr1["YoutubeVideoURL"] = "https://www.youtube.com/watch?v=testid";
            dt.Rows.Add(dr);
            dt.Rows.Add(dr1);
            rpt.DataSource=dt;
            rpt.DataBind();
        
       
        }
    }
    protected string CreateVideoThumbnail(string YoutubeUrl)
    {
        string youTubeThumb = string.Empty;
        if (YoutubeUrl == "")
            return "";

        if (YoutubeUrl.IndexOf("=") > 0)
        {
            youTubeThumb = YoutubeUrl.Split('=')[1];
        }
        else if (YoutubeUrl.IndexOf("/v/") > 0)
        {
            string strVideoCode = YoutubeUrl.Substring(YoutubeUrl.IndexOf("/v/") + 3);
            int ind = strVideoCode.IndexOf("?");
            youTubeThumb = strVideoCode.Substring(0, ind == -1 ? strVideoCode.Length : ind);
        }
        else if (YoutubeUrl.IndexOf('/') < 6)
        {
            youTubeThumb = YoutubeUrl.Split('/')[3];
        }
        else if (YoutubeUrl.IndexOf('/') > 6)
        {
            youTubeThumb = YoutubeUrl.Split('/')[1];
        }

        return "http://img.youtube.com/vi/" + youTubeThumb + "/mqdefault.jpg";
    }    
}

===============================================
.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Repeater ID="rpt" runat="server">
    <ItemTemplate>
    <a href='<%#Eval("YoutubeVideoURL") %>'"> <asp:Image ID="Image1" src='<%# CreateVideoThumbnail((Eval("YoutubeVideoURL").ToString())) %>' runat="server" /> </a> <br />

    </ItemTemplate>
    </asp:Repeater>
      
   
    </form>
</body>
</html>