Saturday, July 21, 2018

HOW TO UPLOAD FILE TO ONEDRIVE USING MVC - (VIEW,EDIT BOTH)

Introduction 
This sample demonstrates how to upload file to OneDrive and to get a share link to share with REST using web application.
When users visit the website, they will be redirected to office 365 to finish the authentication. After that, they will go forward to our website with a code so that they can request REST API for a token.
Next, users will upload the file to OneDrive and receive a file id in return.
Eventually, REST API can be requested with this file id to get the share link which can be used in web, client or mobile.
Sample prerequisites
•Register application for your OneDrive, while the related details will be described in the next section
•Go to the Register and manage apps to register your application.
•After the registration has been prompted, sign in with you Microsoft account credentials in apps.dev.microsoft.com.
And you will see this in your browser.
•Find My applications and click Add an app.
•Enter you app’s name and click Create application.
•Scroll to the page bottom and check the Live ADK support box.
•Below the Application Secrets, generate new password, and then save it for later use.
•Below the Platform's header, create a web app, and then set the Redirect URIs to your web app callback address such as http://localhost:1438/Home/OnAuthComplate.
•Click Save at the very bottom of the page.
Building the sample
•Double-click CSUploadFileToOneDriveAndShare.sln file to open this sample solution using Microsoft Visual Studio 2015 which has the web develop component installed.
•Set project CSUploadFileToOneDriveAndShare as a startup project.
 •Config under parameter in:
Project: CSUploadFileToOneDriveAndShare/Controllers/HomeController.cs
You can find the Clirntld here:
Secret is the key for the application whose password has been shown once when being set up. Therefore, it is better for you to copy it.
You can find CallbackUri here:

Running the sample
•Open the sample solution using Visual studio, then press F5 key or select Debug -> Start Debugging from the menu.
•After the site has been started, you will see this:  
•When you have filled all the fields, click Sign in. Then it will go back to our web application, then you can see this:
•Choose an office file, and then click upload button.  
The file will be uploaded to OneDrive, and a preview page will be rendered.


Using the code
Public field
public string OneDriveApiRoot { get; set; } = "https://api.onedrive.com/v1.0/";

Upload file to OneDrive
//this is main method of upload file to OneDrive
public async Task<string> UploadFileAsync(string filePath, string oneDrivePath)
{
    //get the upload session,we can use this session to upload file resume from break point
    string uploadUri = await GetUploadSession(oneDrivePath);

//when file upload is not finish, the result is upload progress,
//When file upload is finish, the result is the file information.
    string result = string.Empty;
    using (FileStream stream = File.OpenRead(filePath))
    {
        long position = 0;
        long totalLength = stream.Length;
        int length = 10 * 1024 * 1024;

//In one time, we just upload a part of file
        //When all file part is uploaded, break out in this loop
        while (true)
        {
            //Read a file part
            byte[] bytes = await ReadFileFragmentAsync(stream, position, length);

            //check if arrive file end, when yes, break out with this loop
            if (position >= totalLength)
            {
                break;
            }

            //Upload the file part
            result = await UploadFileFragmentAsync(bytes, uploadUri, position, totalLength);

            position += bytes.Length;
        }
    }

    return result;
}

private async Task<string> GetUploadSession(string oneDriveFilePath)
{
    var uploadSession = await AuthRequestToStringAsync(
        uri: $"{OneDriveApiRoot}drive/root:/{oneDriveFilePath}:/upload.createSession",
        httpMethod: HTTPMethod.Post,
        contentType: "application/x-www-form-urlencoded");

    JObject jo = JObject.Parse(uploadSession);

    return jo.SelectToken("uploadUrl").Value<string>();
}

private async Task<string> UploadFileFragmentAsync(byte[] datas, string uploadUri, long position, long totalLength)
{
    var request = await InitAuthRequest(uploadUri, HTTPMethod.Put, datas, null);
    request.Request.Headers.Add("Content-Range", $"bytes {position}-{position + datas.Length - 1}/{totalLength}");

    return await request.GetResponseStringAsync();
}

Get Share Link
//This method use to get ShareLink, you can use the link in web or client terminal
public async Task<string> GetShareLinkAsync(string fileID, OneDriveShareLinkType type, OneDrevShareScopeType scope)
{
    string param = "{type:'" + type + "',scope:'" + scope + "'}";

    string result = await AuthRequestToStringAsync(
        uri: $"{OneDriveApiRoot}drive/items/{fileID}/action.createLink",
        httpMethod: HTTPMethod.Post,
        data: Encoding.UTF8.GetBytes(param),
        contentType: "application/json");

    return JObject.Parse(result).SelectToken("link.webUrl").Value<string>();
}

OUTPUT :



HERE IS THE VIDEO RELATED TO TOPIC


Tuesday, July 3, 2018

HOW TO GENERATE UNIQUE ID(CHARACTER + NUMBER) FOR CUSTOMER IN SQL SERVER

HERE IN THIS SQL Tutorial WE WILL GENERATE UNIQUE ID(CHARACTER + NUMBER) FOR CUSTOMER IN SQL SERVER

Example:
Step 1 :- Create Database

Create Database Bank_db



Step 2:- Create Table

create table Customer{
ID int IDENTITY(1,1) NOT NULL,
PerFix varchar(50) NOT NULL,
CustomerNo AS(PerFix+RIGHT('0000000'+CAST(ID AS VARCHAR(7)),7)) PERSISTED,
CustomerName  varchar(50)
};


Step 3 :-

INSERT INTO Customer (PerFix,CustomerNo) Values('SBI','VIRAJ')
INSERT INTO Customer (PerFix,CustomerNo) Values('SBI','ANIL')
INSERT INTO Customer (PerFix,CustomerNo) Values('SBI','RUPESH')



Step 4 :-  Output

Select CustomerNo,CustomerName From Customer



Here Is The Video Related To Topic


Saturday, June 30, 2018

HOW TO UPLOAD AN IMAGE WHILE SENDING AND EMAIL USING ASP.NET

HERE IN THIS ASP.NET Tutorial  WE WILL UPLOAD AN IMAGE WHILE SENDING AND EMAIL USING ASP.NET

Here, we will see how can we send email using our Gmail SMTP in c# .NET. Generally, for sending an email from one place to another two parties are required -- first is the sender and the second is the receiver. We will use the Mail Message class of  .NET to send an email. For this, we will require a few details:

Sender Email Address
Sender Password
Receiver Email Address
Port Number
EnableSSL property
And most important before we start coding we need to import two namespaces to  access the MailMessage Class:

using System.Net;
using System.Net.Mail;


SMTP Class Properties

Following are the properties of the SMTP class.

Host – SMTP Server URL (Gmail: smtp.gmail.com)

EnableSsl – Specify whether your host accepts SSL Connections (Gmail: True)

UseDefaultCredentials – Set to True in order to allow authentication based on the Credentials of the Account used to send emails

Credentials – Valid login credentials for the SMTP server (Gmail: email address and password)

Port – Port Number of the SMTP server (Gmail: 587)

Step 1 :- WebForm2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication6.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 344px;
        }
        .auto-style2 {
            width: 121%;
        }
    </style>
</head>
<body style="width: 466px; height: 78px">
    <form id="form1" runat="server">
        <div>
            <table class="auto-style2">
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label1" runat="server" Text="FROM :-"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server" Width="246px"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label2" runat="server" Text="TO :-"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox2" runat="server" Width="246px"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label3" runat="server" Text="UPLOAD IMAGE :-"></asp:Label>
                    </td>
                    <td>
                        <asp:FileUpload ID="FileUpload1" runat="server" />
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label5" runat="server" Text="VISITOR NAME :-"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox3" runat="server" Width="246px"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label6" runat="server" Text="VISITOR COMPANY NAME :-"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox4" runat="server" Width="246px"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label7" runat="server" Text="VISITOR CONTACT NO :-"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox5" runat="server" Width="246px"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label8" runat="server" Text="MEETING TO :-"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox6" runat="server" Width="246px"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">&nbsp;</td>
                    <td>
                        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="SUBMIT" />
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style1">&nbsp;</td>
                    <td>
                        <asp:Label ID="Label4" runat="server" ForeColor="Lime"></asp:Label>
                    </td>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

Step 2 :- C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net;
using System.Net.Mail;

namespace WebApplication6
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string folderPath = Server.MapPath("~/Files/");

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }
            FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName));

            string text = @"<html><body>" +
                "<h3><b>This Person Is Coming For Official Visit.</b></h3>" +
                "<table>" +
                "<tr><td width=150px>Visitor Image :</td><td><img src='cid:image1' height=70px width=70px></td></tr>" +
                "<tr><td width=150px>Visitor Name :</td><td>" + TextBox3.Text.ToString() + "</td></tr>" +
                "<tr><td width=150px>Visitor Company :</td><td>" + TextBox4.Text.ToString() + "</td></tr>" +
                "<tr><td width=150px>Visitor ContactNo :</td><td>" + TextBox5.Text.ToString() + "</td></tr>" +
                "<tr><td width=150px>Meeting To :</td><td>" + TextBox6.Text.ToString() + "</td></tr>" +
                "<tr><td width=150px>Purpose :</td><td>Official Visit</td></tr>" +
                "<tr><td width=150px>Date :</td><td>" + System.DateTime.Now.ToString() + "</td></tr>" +
                "</table>" +
                "</body></html>";

            using (MailMessage mm = new MailMessage(TextBox1.Text.ToString(), TextBox2.Text.ToString()))
            {
                AlternateView htmlview = default(AlternateView);
                htmlview = AlternateView.CreateAlternateViewFromString(text, null, "text/html");
                LinkedResource imageResourceEs = new LinkedResource(Server.MapPath("~/Files/" + FileUpload1.FileName.ToString()), "image/jpg");
                imageResourceEs.ContentId = "image1";
                imageResourceEs.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
                htmlview.LinkedResources.Add(imageResourceEs);
                mm.Subject = "Visitor Notification";
                mm.Body = text;
                mm.IsBodyHtml = true;
                mm.AlternateViews.Add(htmlview);

                using (SmtpClient smtp = new SmtpClient())
                {
                    smtp.Host = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential("user@gmail.com","password");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                    Label4.Text = "Email Sent";

                }
            }

        }
    }
}

Output :-

























Here Is An Video Related To Topic In This Blog


Thursday, June 28, 2018

HOW TO GENERATE AND READ QR CODE IN ASP.NET

HERE IN THIS .Net Tutorial WE WILL GENERATE AND READ QR CODE IN ASP.NET

Here we will learn how to create or generate QR code in asp.net web application using c# with example or asp.net dynamically generate and display QR code using c# with example or generate and read QR code in asp.net using zxing.Net library in c# with example. By using “Zxing.Net” library in asp.net we can easily generate and read QR code in c# with example based on our requirements.
In asp.net by using “Zxing.Net” library we can generate QR code and read data from that image based on our requirements.

To use “Zxing.Net” library in our application first create new asp.net web application and add Zxing.Net library for that right click on your application à select Manage Nuget Packages à Go to Browse Tab à Search for Zxing.Net à From the list select ZxingNet and install it. Once we install the component that will show like as shown following.








Once we install Zxing.Net package in our application now open your aspx page and write the code like as shown following.


Step 1 :- WebForm1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication5.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Generate and Read QR Code in Asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
            <asp:Button ID="btnGenerate" runat="server" Text="Generate QR Code" OnClick="btnGenerate_Click"/>
            <hr/>
            <asp:Image ID="imgQRCode" Width="100px" Height="100px" runat="server" Visible="false"/>
            <br/><br/>
             <asp:Button ID="btnRead" runat="server" Text="Read QR Image" OnClick="btnRead_Click"/>
            <br/><br/>
            <asp:Label ID="lblQRCode" runat="server"></asp:Label>
        </div>
    </form>
</body>
</html>

Step 2 :- C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using ZXing;

namespace WebApplication5
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            GenerateCode(txtCode.Text);
        }

        protected void btnRead_Click(object sender, EventArgs e)
        {
            ReadQRCode();
        }
        //Generate QRCode
        private void GenerateCode(string name)
        {
            var writer = new BarcodeWriter();
            writer.Format = BarcodeFormat.QR_CODE;
            var result = writer.Write(name);
            string path = Server.MapPath("~/images/QRImage.jpg");
            var barcodeBitmap = new Bitmap(result);


            using (MemoryStream memory = new MemoryStream())
            {
                using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
                {
                    barcodeBitmap.Save(memory, ImageFormat.Jpeg);
                    byte[] bytes = memory.ToArray();
                    fs.Write(bytes, 0, bytes.Length);
                }
            }
            imgQRCode.Visible = true;
            imgQRCode.ImageUrl = "~/images/QRImage.jpg";
        }

        //Read Code from QR Image
        private void ReadQRCode()
        {
            var reader = new BarcodeReader();
            string filename = Path.Combine(Request.MapPath("~/images"), "QRImage.jpg");
            //Detech and decode the barcode inside the bitmap
            var result = reader.Decode(new Bitmap(filename));
            if (result != null)
            {
                lblQRCode.Text = "QR Code :  " + result.Text;
            }
        }
    }
}

Output :-
Enter Text I TexBox












Click On Generate Qr Code Button












Now Click On Read Qr Image














Qr Image Is Also Save In Images Folder





Video Related To This Topic Is Here Below.
HOW TO GENERATE AND READ QR CODE IN ASP.NET




Wednesday, June 27, 2018

HOW TO CREATE BASIC GST CALCULATOR IN ASP.NET - (ADD GST AND REMOVE GST)

HERE IN THIS .NET Tutorial WE WILL CREATE BASIC GST CALCULATOR IN ASP.NET - (ADD GST AND REMOVE GST)

GST Tax Calculation Formula
All one needs to do is input the net amount of a good or service and the applicable GST rate (5%, 12%, 18% or 28%) into the tool. Click on the 'Calculate' button and instantly get the gross price of the good or service. GST calculation is represented by the below example:

A goods or service is sold at the rate of Rs.500. GST rate is 18%. Gross amount of the goods or service = 500 + [500 x (18/100)] = Rs.590

Formula for GST calculation:

Add GST:
-----------------------------------------------------------------------------------------------------------------------------
GST Amount = (Original Cost x (GST% /100) )

Net Price = Original Cost + GST Amount
-------------------------------------------------------------------------------------------------------------------------------
Original Cost=500
GST%= 18%
GST Convert=(18/100)=0.18
GST Amount =Original Cost * GST Convert
GST Amount = 500 * 0.18=90
Net Price = Original Cost + GST Amount
Net Price = 500 +90=Rs 590.

-------------------------------------------------------------------------------------------------------------------------------
Remove GST:
GST Amount = Original Cost - [Original Cost x {100/(100+GST%)}]

Net Price = Original Cost - GST Amount
--------------------------------------------------------------------------------------------------------------------------------
Original Cost=500
GST%= 18%
GST Amount = Original Cost - [Original Cost x {100/(100+GST%)}]
GST Amount = 500 - [500 x {100/(100+18)}]=76.271186
Net Price = Original Cost - GST Amount
Net Price = 500 - 76.271186=423.728814

As Per Indian GST System.

So Let Begin With Coding

Step1 :- Design Form And Save As Default.aspx

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

<!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>
    <style type="text/css">
        .style1
        {
            width: 112px;
        }
    </style>
</head>
<body style="height: 75px; width: 575px">
    <form id="form1" runat="server">
    <div>
   
        <table style="width: 62%; height: 71px;">
            <tr>
                <td class="style1">
                    <asp:Label ID="Label1" runat="server" Text="Original Cost :-"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="Label2" runat="server" Text="GST% :-"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
                        Text="Add GST" />
&nbsp;
                    <asp:Button ID="Button2" runat="server" onclick="Button2_Click"
                        Text="Remove GST" />
                </td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Net Price :-"></asp:Label>
&nbsp;
                    <asp:Label ID="Label4" runat="server" Font-Bold="True" ForeColor="#00CC00"></asp:Label>
                </td>
            </tr>
        </table>
   
    </div>
    </form>
</body>
</html>

Step 2 : C# Code

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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        decimal OriginalCost = Convert.ToDecimal(TextBox1.Text);
        decimal GST = (Convert.ToDecimal(TextBox2.Text)/100);
        decimal GSTAmount = (OriginalCost + (OriginalCost * GST));
        Label4.Text = GSTAmount.ToString();
   
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        decimal OriginalCost = Convert.ToDecimal(TextBox1.Text);
        decimal GST = Convert.ToDecimal(TextBox2.Text);
        decimal GSTAmount = (OriginalCost - (OriginalCost * (100/(100+GST))));
        decimal NetPrice = OriginalCost - GSTAmount;
        Label4.Text = NetPrice.ToString();
   
    }
}

Output :-





Add GST




REMOVE GST




Video Related To This Topic Is Here Below.
HOW TO CREATE BASIC GST CALCULATOR IN ASP.NET - (ADD GST AND REMOVE GST)


Sunday, June 24, 2018

HOW TO SEND EMAIL FROM GMAIL SMTP SERVER IN ASP.NET

Introduction:
HERE IN THIS ASP.NET Tutorial  WE WILL USE  TO SEND EMAIL FROM EMAIL SMTP SERVER IN ASP.NET.


Here, we will see how can we send email using our Gmail SMTP in c# .NET. Generally, for sending an email from one place to another two parties are required -- first is the sender and the second is the receiver. We will use the Mail Message class of  .NET to send an email. For this, we will require a few details:
  1. Sender Email Address
  2. Sender Password
  3. Receiver Email Address
  4. Port Number
  5. EnableSSL property
And most important before we start coding we need to import two namespaces to  access the MailMessage Class:
  • using System.Net;
  • using System.Net.Mail;


SMTP Class Properties
Following are the properties of the SMTP class.
Host – SMTP Server URL (Gmail: smtp.gmail.com)
EnableSsl – Specify whether your host accepts SSL Connections (Gmail: True)
UseDefaultCredentials – Set to True in order to allow authentication based on the Credentials of the Account used to send emails
Credentials – Valid login credentials for the SMTP server (Gmail: email address and password)
Port – Port Number of the SMTP server (Gmail: 587)


Default2.aspx.cs :-

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

<!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>
    <style type="text/css">
        .style1
        {
            width: 87px;
        }
    </style>
</head>
<body style="height: 126px; width: 708px">
    <form id="form1" runat="server">
    <div>
 
        <table style="width:100%;">
            <tr>
                <td class="style1">
                    <asp:Label ID="Label1" runat="server" Text="FROM :"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server" Width="210px"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="Label2" runat="server" Text="TO :"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" Width="210px"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style1">
                    &nbsp;</td>
                <td>
                    <asp:Label ID="Label3" runat="server" ForeColor="Lime"></asp:Label>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
 
    </div>
    </form>
</body>
</html>

C# Code :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net.Mail;
using System.Net;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        using (MailMessage mm = new MailMessage(TextBox1.Text.ToString(), TextBox2.Text.ToString()))
        {
            mm.Subject = "Admin Notification";
            mm.Body = "Email Send By   " + TextBox1.Text.ToString() + ".";
            mm.IsBodyHtml = true;
            using (SmtpClient smtp = new SmtpClient())
            {
                smtp.Host = "smtp.gmail.com";
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential("your@gmail.com", "abc");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = NetworkCred;
                smtp.Port = 587;
                smtp.Send(mm);
                Label3.Text = "Email Send.......";
                 
            }
        }
    }
}

Output :-



























Here Is An Video Related To Topic In This Blog



Saturday, June 23, 2018

How To Display Dtube Video On Your Web Page

Hello Friends My Name Is Viraj,Today I Will Display Dtube Video On Your Web Page.
Embedding a video into a web page used to be a real challenge in the early days of the web.
You had different formats to chose from, other visitors might not have the proper software installed to see the video, and bandwidth was still limited, as many people were still on dialup. Forward to 2011.

How To Display Dtube Video Link On Your Web Page In Html Code.Here I Would Like To Show An Sample Example Related To Html Tutorial.
This Video Is Available On Dtube Which Is Display In My Code.
Here In This Example We Required Dube Embed Link Which Will Be Written In src As Show In Code And Height And Width Will Be Set In <iframe> Tag.
Let Begin With Our Example.
So Let Begin With Our Coding............

Step 1 :- Select The Video Which You Wanted To Display On Your Webpage

Click On My Channel













Choose Your Video To Display On WebPage













Open Your Video













Select And Choose Option Copy Embed















Step 2 :- Open Notepad Start Writing Code
And Paste Copy Embed Link Inside The Body Tag.

<!DOCTYPE html>
<html>
<head>
<title>How To Display DTUBE Video On Your WebPage</title>
<body>
<iframe width="560" height="315" src="https://emb.d.tube/#!/virajtakke09/qut7u85t" frameborder="0" allowfullscreen></iframe>
</body>
<head>
</html>

And SaveAs Dtube.html

Output :-















Saturday, February 10, 2018

SQL PRIMARY KEY Constraint And SQL FOREIGN KEY Constraint

The PRIMARY KEY constraint uniquely identifies each record in a database table.Primary keys must contain UNIQUE values, and cannot contain NULL values.A table can have only one primary key, which may consist of single or multiple fields.A FOREIGN KEY is a key used to link two tables together.
A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another table.The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table.A primary key is a special relational database table column (or combination of columns) designated to uniquely identify all table records. A primary key'smain features are: It must contain a unique value for each row of data. It cannot contain null values.A primary key, also called a primary keyword, is a key in a relational database that is unique for each record. It is a unique identifier, such as a driver license number, telephone number (including area code), or vehicle identification number (VIN). A relational database must always have one and only one primary key.A primary key is a field or set of fields with values that are unique throughout a table. Values of the key can be used to refer to entire records, because each record has a different value for the key. Each table can only have one primary key. ... To set a table's primary key, open the table in Design view.Choosing a primary key is one of the most important steps in good database design. A primary key is a table column that serves a special purpose. Each database table needs a primary key because it ensures row-level accessibility. ... The values that compose a primary key column are unique; no two values are the same.A primary key is data that is unique to each record in a database or file. This prevents any records from having the same value.Primary Key is used to identify a row (record) in a table, whereas Unique-key is to prevent duplicate values in a column (with the exception of a null entry). By default SQL-engine creates Clustered Index on primary-key if not exists and Non-Clustered Index on Unique-key.A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. ... Instead, the leaf nodes contain index rows.”A surrogate key is any column or set of columns that can be declared as the primary key instead of a "real" or natural key. Sometimes there can be several natural keys that could be declared as the primary key, and these are all called candidate keys. So a surrogate is a candidate key.A primary key is a special relational database table column (or combination of columns) designated to uniquely identify all table records. A primary key's main features are: It must contain a unique value for each row of data. It cannot contain null values.The main purpose of a primary key is to implement a relationship between two tables in a relational database; it's not called a relational database for nothing! More specifically, the primary key is the "target" which a foreign key can reference.

A foreign key is a key used to link two tables together. This is sometimes also called as a referencing key.A Foreign Key is a column or a combination of columns whose values match a Primary Key in a different table.The relationship between 2 tables matches the Primary Key in one of the tables with a Foreign Key in the second table.If a table has a primary key defined on any field(s), then you cannot have two records having the same value of that field(s).A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.SQL > Constraint > Foreign Key. A foreign key is a column (or columns) that references a column (most often the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables. The FOREIGN KEY constraint also prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the table it points to.A primary key is a column or a set of columns that uniquely identify a row in a table. A primary key should be short, stable and simple. A foreign key is a field (or collection of fields) in a table whose value is required to match the value of theprimary key for a second table. ... A table can have multiple foreign keys.Primary keys always need to be unique, foreign keys need to allow non-unique values if the table is a one-to-many relationship. It is perfectly fine to use a foreign key as the primary key if the table is connected by a one-to-one relationship, not a one-to-many relationship.You can create foreign key on columns that are PK or Unuque : ... AFOREIGN KEY constraint does not have to be linked only to a PRIMARY KEYconstraint in another table; it can also be defined to reference the columns of a UNIQUE constraint in another table.

Thursday, February 1, 2018

How To Drop Database In Mssql

Hello Friend Today In This Blog I Will Show You How To Drop Database In Mssql.The DROP DATABASE statement is used to drop an existing SQL database.DROP DATABASE returns the number of tables that were removed. This corresponds to the number of .frm files removed. The DROP DATABASE statementremoves from the given database directory those files and directories that MySQL itself may create during normal operation: All files with the following extensions.The SQL DROP DATABASE statement is used to drop an existing database in SQL schema.The DROP DATABASE Statement is used to drop or delete a database. Dropping of the database will drop all database objects (tables, views, procedures etc.) inside it. The user should have admin privileges for deleting a database.DROP is a powerful statement. A backup of data for a database to be deleted or drop is a the best quick cheap recovery solution. So be smart with this statement!To use DROP DATABASE, one needs to have the DROP privilege on the database.You can easily remove or delete indexes, tables and databases with the DROP statement.DROP DATABASE drops all tables in the database and deletes the database. Be very careful with this statement! To use DROP DATABASE, you need the DROP privilege on the database. DROP SCHEMA is a synonym for DROP DATABASE.IF EXISTS is used to prevent an error from occurring if the database does not exist.


If the default database is dropped, the default database is unset (the DATABASE() function returns NULL).If you use DROP DATABASE on a symbolically linked database, both the link and the original database are deleted.DROP DATABASE returns the number of tables that were removed. This corresponds to the number of .frm files removed.If other files or directories remain in the database directory after MySQL removes those just listed, the database directory cannot be removed. In this case, you must remove any remaining files or directories manually and issue the DROP DATABASE statement again.DROP DATABASE drops all tables in the database and deletes the database. Be very careful with this statement! To use DROP DATABASE, you need the DROP privilege on the database. DROP SCHEMA is a synonym for DROP DATABASE.SQL provides DROP DATABASE statement to allow you to remove existing databases. The SQL DROP DATABASE statement deletes all tables, views, triggers, and other related objects inside a database, and also removes the database permanently.Sometimes we may decide that we need to delete of an entire database in the RDBMS. In fact, if we cannot do so, we would be faced with a maintenance nightmare. Fortunately, SQL allows us to do it, as we can use the DROP DATABASE command. The DROP DATABASE statement is used for deleting a database and all of its tables completely.After dropping a database you can check the database list to cross verify that the database has been successfully dropped or not.Use the DROP DATABASE command to delete the target database and, if RMAN is connected to a recovery catalog, unregister it. RMAN removes all data files, online redo logs, and control files belonging to the target database. By default, RMAN prompts for confirmation.

Syntax

DROP DATABASE databasename;


Step 1 :Create database


Create database Employee



Step 2:Create table

Here In This step We Will Create table.

Here In This Step We Required Four Column With Name eids ,ename ,edept and esalary using Parameter bigint,varchar and float.

create table emp
(
eids bigint,
ename varchar(50),
edept varchar(50),
esalary float
);



Step 3 :Drop Database Using Database Name

DROP DATABASE Employee;


How To Use Different Type Of Mssql Joins

Hello Friend Today In This Blog I Will Show You How To Use Different Type Of Mssql Joins .A JOIN clause is used to combine rows from two or more tables, based on a related column between them.The INNER JOIN keyword selects records that have matching values in both tables.The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match.The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match.The FULL OUTER JOIN keyword return all records when there is a match in either left (table1) or right (table2) table records.A self JOIN is a regular join, but the table is joined with itself.A SQL JOIN combines records from two tables.A JOIN locates related column values in the two tables.A query can contain zero, one, or multiple JOIN operations.INNER JOIN is the same as JOIN; the keyword INNER is optional.(INNER) JOIN: Select records that have matching values in both tables.LEFT (OUTER) JOIN: Select records from the first (left-most) table with matching right table records.RIGHT (OUTER) JOIN: Select records from the second (right-most) table with matching left table records.FULL (OUTER) JOIN: Selects all records that match either left or right table records.The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.Here, it is noticeable that the join is performed in the WHERE clause. Several operators can be used to join tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables. However, the most common operator is the equal to symbol.A SQL Join statement is used to combine data or rows from two or more tables based on a common field between them.INNER JOIN: The INNER JOIN keyword selects all rows from both the tables as long as the condition satisfies. This keyword will create the result-set by combining all rows from both the tables where the condition satisfies i.e value of the common field will be same.LEFT JOIN: This join returns all the rows of the table on the left side of the join and matching rows for the table on the right side of join. The rows for which there is no matching row on right side, the result-set will contain null.RIGHT JOIN: RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows of the table on the right side of the join and matching rows for the table on the left side of join. The rows for which there is no matching row on left side, the result-set will contain null. FULL JOIN: FULL JOIN creates the result-set by combining result of both LEFT JOIN and RIGHT JOIN. The result-set will contain all the rows from both the tables. The rows for which there is no matching, the result-set will contain NULL values.There are four basic types of SQL joins: inner, left, right, and full. The easiest and most intuitive way to explain the difference between these four types is by using a Venn diagram, which shows all possible logical relations between data sets. Let's use the tables we introduced in the “What is a SQL join?” section to show examples of these joins in action. The relationship between the two tables is specified by the customer_id key, which is the "primary key" in customers table and a "foreign key" in the orders table.Let’s say we wanted to get a list of those customers who placed an order and the details of the order they placed. This would be a perfect fit for an inner join, since an inner join returns records at the intersection of the two tables.If we wanted to simply append information about orders to our customers table, regardless of whether a customer placed an order or not, we would use a left join. A left join returns all records from table A and any matching records from table B.Right join is a mirror version of the left join and allows to get a list of all orders, appended with customer information.Finally, for a list of all records from both tables, we can use a full join.A SQL join is a Structured Query Language (SQL) instruction to combine data from two sets of data (i.e. two tables). Before we dive into the details of a SQL join, let’s briefly discuss what SQL is, and why someone would want to perform a SQL join.SQL is a special-purpose programming language designed for managing information in a relational database management system (RDBMS). The word relational here is key; it specifies that the database management system is organized in such a way that there are clear relations defined between different sets of data. Typically, you need to extract, transform, and load data into your RDBMS before you’re able to manage it using SQL, which you can accomplish by using a tool like Stitch.An SQL JOIN clause combines rows from two or more tables. It creates a set of rows in a temporary table.A JOIN works on two or more tables if they have at least one common field and have a relationship between them.JOIN keeps the base tables (structure and data) unchanged.

Different Types of SQL JOINs
Here are the different types of the JOINs in SQL:

(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Return all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Return all records from the right table, and the matched records from the left table

FULL (OUTER) JOIN: Return all records when there is a match in either left or right table


INNER JOIN Syntax

SELECT column_name(s)
FROM table1

INNER JOIN table2 ON table1.column_name = table2.column_name;

LEFT JOIN Syntax

SELECT column_name(s)
FROM table1

LEFT JOIN table2 ON table1.column_name = table2.column_name;

RIGHT JOIN Syntax

SELECT column_name(s)
FROM table1

RIGHT JOIN table2 ON table1.column_name = table2.column_name;

FULL OUTER JOIN Syntax

SELECT column_name(s)
FROM table1

FULL OUTER JOIN table2 ON table1.column_name = table2.column_name;


Step 1 :Create database

Create database BMC





Step 2:Create table

Here In This step We Will Create Two table.


Here In This Step We Required Four Column With Name eid ,ename ,city And did using Parameter bigint and varchar.

 create table employee
 (
 eid bigint,
 ename varchar(25),
 city varchar(25),
 did bigint,
 );

Here In This Step We Required Four Column With Name did and deptname using Parameter bigint and varchar.

  create table department
  (
  did bigint,
  deptname varchar(25)

  );




Step 3 :Create Insert Trigger Functionality

Here In This Step We Will Insert Data Using Insert Command.

Data Will Be Added Manually Using Insert Command.

insert into employee values(1,'VIRAJ','MUMBAI',101)
insert into employee values(2,'RAJ','PUNE',102)
insert into employee values(3,'RAM','DELHI',101)
insert into employee values(4,'RAJU','MUMBAI',103)
insert into employee values(5,'RAMU','NAVI MUMBAI',102)
insert into employee values(6,'ANIL','PUNE',101)

insert into department values(101,'IT')
insert into department values(102,'HR')
insert into department values(103,'SALES')

select *from employee


select *from department




Step 4 :Use Different Type Of Mssql Joins Functionality.

INNER JOIN

SELECT employee.eid,employee.ename,employee.city,department.did,department.deptname
FROM employee

INNER JOIN department ON employee.did = department.did;



LEFT JOIN

SELECT employee.eid,employee.ename,employee.city,department.did
FROM employee

LEFT JOIN department ON employee.did = department.did;



RIGHT JOIN

SELECT employee.eid,employee.ename,employee.city,department.did,department.deptname
FROM employee

RIGHT JOIN department ON employee.did = department.did;


FULL OUTER JOIN

SELECT employee.eid,employee.ename,employee.city,department.did,department.deptname
FROM employee

FULL OUTER JOIN department ON employee.did = department.did;



Here Is An Video Related To Topic In This Blog