Thursday 19 December 2013

Coding For Change DataTime Format in System

RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
rkey.SetValue("sShortDate", "dd/MM/yyyy"); 

How to Set Secure Password in Login Table of Database




DESIGN



AFTER  CLICK A SAVE BUTTON

      private void butSave_Click(object sender, EventArgs e)
      {
                    SqlConnection con = new SqlConnection(conn);
                    con.Open();
                    string un = txtUserName.Text.ToString().Trim();
                    string pw = txtPassword.Text.ToString().Trim();

                    string pass = "";
                    byte[] asciiBytes = Encoding.ASCII.GetBytes(pw);
                    for (int i = 0; i < pw.Length; i++)
                    {
                        int pw1 = asciiBytes[i] - 24;
                        string sssss = ((char)pw1).ToString();
                        pass = pass + sssss;
                    }

                    int op = 0;
                    if (radioEmployee.Checked == true)
                    {
                        op = 0;
                    }
                    else if(radioOwner.Checked == true)
                    {
                        op = 1;
                    }

                    string query = "insert into LOGIN(User_Name,Pass_Word,Owner_Permission)                                   values('" + un + "','" + pass + "','" + op + "')";
                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Saved Successfully");
       }


LOGIN FORM



LOGIN CLICK BUTTON (UserName and Password Checking from Database)


        private void butLogin_Click(object sender, EventArgs e)
        {
                SqlConnection con = new SqlConnection(conn);
                con.Open();
                string un = txtUsername.Text.ToString().Trim();
                string pw = txtPassword.Text.ToString().Trim(); 
                string find = "select * from IBS_LOGIN where User_Name = '" + un + "' and Pass_Word =                 '" + pass + "'";
                    SqlCommand findquery = new SqlCommand(find, con);
                    SqlDataReader dr = findquery.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr["Owner_Permission"].ToString() == "1")
                        {
                            GlobalDeclare.linknewaccount = 1;
                        }
                        else
                        {
                            GlobalDeclare.linknewaccount = 0;
                        }
                        if (dr["User_Name"].ToString() == un && dr["Pass_Word"].ToString() == pass)
                        {                           
                            RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@"Control                                                     Panel\International", true);
                            rkey.SetValue("sShortDate", "dd/MM/yyyy");  
                            
                            IBSSTOCK ibs = new IBSSTOCK();
                            ibs.Show();                                                        
                        }
                        else
                        {
                            MessageBox.Show("Not Valid.User Name and Password Is Worng.");
                            dr.Close();
                        } 
        }



How to Convert String to ASCII Format and ASCII Format to String Format in C#

 string a = "abc";
 byte[] asciiBytes = Encoding.ASCII.GetBytes(a);
 for (int i = 0; i < a.Length; i++)
 {
       int b = asciiBytes[i];                         // string to ascii value
       string sssss = ((char)b).ToString();   // ascii value to string        
 }


How to clear recent projects in Start Page of Visual Studio 2008

Example Image


To remove the projects from the list, follow these steps:

  • Close Visual Studio if it is running.
  • Start the Registry Editor (run regedit).










  • Navigate to this registry key: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList
  • Then delete the key that has the project you do not want to keep in the list.

Now Open a Visual Studio 8.0




Send Email in aspx Page Live coding

First Enable GMAIL Account


In a Solution File

Create a Folder Name :  EmailAttachment

Example Image:



Design Page


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Email.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>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 245px;
        }
        .style3
        {
            width: 124px;
        }
        .style4
        {
            width: 245px;
            height: 134px;
        }
        .style5
        {
            width: 124px;
            height: 134px;
        }
        .style6
        {
            height: 134px;
        }
        .style7
        {
            width: 245px;
            height: 23px;
        }
        .style8
        {
            width: 124px;
            height: 23px;
        }
        .style9
        {
            height: 23px;
        }
    </style>
    
    <script language="javascript" type="text/javascript">
        function ValidateFileUploadExtension(Source, args) {
            var fupData = document.getElementById('<%= FileUpload1.ClientID %>');
            var FileUploadPath = fupData.value;

            if (FileUploadPath == '') {
                // There is no file selected
                alert("Please select image");
            }
            else {
                var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();

                if (Extension == "gif" || Extension == "jpeg" || Extension == "jpg" || Extension == "png") {
                    args.IsValid = true; // Valid file type
                }
                else {
                    args.IsValid = false; // Not valid file type
                }
            }
        }

        function ValidateFileUploadExtension1(Source, args) {
            var fupData = document.getElementById('<%= FileUpload2.ClientID %>');
            var FileUploadPath = fupData.value;

            if (FileUploadPath == '') {
                // There is no file selected
                alert("Please select image");
            }
            else {
                var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();

                if (Extension == "gif" || Extension == "jpeg" || Extension == "jpg" || Extension == "png") {
                    args.IsValid = true; // Valid file type
                }
                else {
                    args.IsValid = false; // Not valid file type
                }
            }
        }

        function ValidateFileUploadExtension2(Source, args) {
            var fupData = document.getElementById('<%= FileUpload3.ClientID %>');
            var FileUploadPath = fupData.value;

            if (FileUploadPath == '') {
                // There is no file selected
                alert("Please select image");
            }
            else {
                var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();

                if (Extension == "gif" || Extension == "jpeg" || Extension == "jpg" || Extension == "png") {
                    args.IsValid = true; // Valid file type
                }
                else {
                    args.IsValid = false; // Not valid file type
                }
            }
        }
</script>     
</head>
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
    <div style="height: 426px">
    
        <br />
        <br />
        <table class="style1">
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    Welcome Admin,</td>
                <td align ="right" >
                    <asp:LinkButton ID="LinkLogout" runat="server" CausesValidation="False" 
                        onclick="LinkLogout_Click">Logout</asp:LinkButton>
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    To</td>
                <td>
                    <asp:TextBox ID="txtToAddress" runat="server" Width="318px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="txtToAddress" ErrorMessage="Enter a Email Address">*</asp:RequiredFieldValidator>
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    Subject</td>
                <td>
                    <asp:TextBox ID="txtSubject" runat="server" Width="318px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ControlToValidate="txtSubject" ErrorMessage="Enter a Subject">*</asp:RequiredFieldValidator>
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style4">
                </td>
                <td class="style5">
                    Message</td>
                <td class="style6">
                    <asp:TextBox ID="txtMessage" runat="server" Height="96px" TextMode="MultiLine" 
                        Width="349px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                        ControlToValidate="txtMessage" ErrorMessage="Enter a Message">*</asp:RequiredFieldValidator>
                </td>
                <td class="style6">
                </td>
                <td class="style6">
                </td>
            </tr>
            <tr>
                <td class="style7">
                </td>
                <td class="style8">
                    Select Image</td>
                <td class="style9">
    <asp:FileUpload ID="FileUpload1" runat="server" Width="223px" />
                <asp:CustomValidator ID="CustomValidator1" runat="server"
 ClientValidationFunction="ValidateFileUploadExtension" 
                        ErrorMessage="Please select valid image file 1" Font-Size="16px" ForeColor="red" 
                        ControlToValidate="FileUpload1">*</asp:CustomValidator>
                    <asp:LinkButton ID="LinkAdd1" runat="server" onclick="LinkAdd1_Click" 
                        CausesValidation="False">Add Additional Image</asp:LinkButton>
                </td>
                <td class="style9">
                </td>
                <td class="style9">
                </td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    &nbsp;</td>
                <td>
    <asp:FileUpload ID="FileUpload2" runat="server" Visible="False" Width="222px" />
                <asp:CustomValidator ID="CustomValidator2" runat="server"
 ClientValidationFunction="ValidateFileUploadExtension1" ErrorMessage="Please select valid image file 2" 
                        Font-Size="16px" ForeColor="red" ControlToValidate="FileUpload2">*</asp:CustomValidator>
                    <asp:LinkButton ID="LinkAdd2" runat="server" onclick="LinkAdd2_Click" 
                        Visible="False" CausesValidation="False">Add Additional Image</asp:LinkButton>
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    &nbsp;</td>
                <td>
    <asp:FileUpload ID="FileUpload3" runat="server" Visible="False" Width="219px" />
                &nbsp;<asp:CustomValidator ID="CustomValidator3" runat="server"
 ClientValidationFunction="ValidateFileUploadExtension2" ErrorMessage="Please select valid image file 3" 
                        Font-Size="16px" ForeColor="red" ControlToValidate="FileUpload3">*</asp:CustomValidator></td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
    
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Send Mail" />
    
                </td>
                <td>
    <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Cancel" 
                        CausesValidation="False" Height="26px" />
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                </td>
                <td class="style3">
                </td>
                <td>
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                        ShowMessageBox="True" ShowSummary="False" />
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>

Coding Page


using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net.Mail;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == "")
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
           
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string to = txtToAddress.Text.ToString().Trim();
        string from = "yourmailid@gmail.com";
        string password = "yourpassword";
        string subject = txtSubject.Text.ToString().Trim();
        string Message = txtMessage.Text.ToString().Trim();
        string host = "smtp.gmail.com";
        int port = 587; 
        
        MailMessage email = new MailMessage();
        email.From = new MailAddress(from);
        email.Subject = subject;
        email.Body = Message;
        SmtpClient smtp = new SmtpClient(host, port);
        smtp.UseDefaultCredentials = false;
        NetworkCredential nc = new NetworkCredential(from, password);
        smtp.Credentials = nc;
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network; 
        smtp.EnableSsl = true;
        email.IsBodyHtml = true;   

        email.To.Add(new MailAddress(to));

        string fileName = "";
        if (FileUpload1.PostedFile != null)
        {
            HttpPostedFile attchment = FileUpload1.PostedFile;
            int FileLength = attchment.ContentLength;
            if (FileLength > 0)
            {
                fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                FileUpload1.PostedFile.SaveAs(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName));
                Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName));
                email.Attachments.Add(attachment);                
            }
        }

        if (FileUpload2.PostedFile != null)
        {
            HttpPostedFile attchment = FileUpload2.PostedFile;
            int FileLength = attchment.ContentLength;
            if (FileLength > 0)
            {
                fileName = Path.GetFileName(FileUpload2.PostedFile.FileName);
                FileUpload2.PostedFile.SaveAs(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName));
                Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName));
                email.Attachments.Add(attachment);
            }
        }

        if (FileUpload3.PostedFile != null)
        {
            HttpPostedFile attchment = FileUpload3.PostedFile;
            int FileLength = attchment.ContentLength;
            if (FileLength > 0)
            {
                fileName = Path.GetFileName(FileUpload3.PostedFile.FileName);
                FileUpload3.PostedFile.SaveAs(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName));
                Attachment attachment = new Attachment(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName));
                email.Attachments.Add(attachment);
            }
        }        

        smtp.Send(email);
        email.Dispose();

        string[] fileNames = Directory.GetFiles(Server.MapPath("~/SendEmail/EmailAttachment"));
        foreach (string fileName1 in fileNames)
            File.Delete(Path.Combine(Server.MapPath("~/SendEmail/EmailAttachment"), fileName1));


        clear();
    }

    private void clear()
    {
        LinkAdd2.Visible = false;
        FileUpload2.Visible = false;       
        FileUpload3.Visible = false;        

        txtToAddress.Text = "";
        txtSubject.Text = "";
        txtMessage.Text = "";       
    }

    protected void Button2_Click(object sender, EventArgs e)
    {        
        clear();        
    }
    protected void LinkAdd1_Click(object sender, EventArgs e)
    {
        LinkAdd2.Visible = true;
        FileUpload2.Visible = true;
    }

    protected void LinkAdd2_Click(object sender, EventArgs e)
    {        
        FileUpload3.Visible = true;
    }    
    
    protected void LinkLogout_Click(object sender, EventArgs e)
    {
        Session["user"] = "";
        Response.Redirect("Login.aspx");
    }    
}

Web.config File

<?xml version="1.0"?>

<configuration>
  <connectionStrings>
    <clear/>    
  </connectionStrings>

  <system.web>
      <compilation defaultLanguage="c#" debug="true" />
    <customErrors mode="Off"/>    
  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>   


</configuration>



Monday 16 September 2013

Auto Numbering in Grid View in Asp.net


Add S.No column in grid view 

                         
                            <asp:TemplateField HeaderText="SNO">
                               <ItemTemplate>
                                   <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>                    
                       

Output:

                 




Friday 13 September 2013

Convert Excel From SQL Data Base in C# Windows Application

Step 1:

First, you need to add Microsoft.Office.Interop.Excel as a reference 




Step 2:

private void GridDesign()
{
            dgvAdd.Columns.Add("docno", "Doc_No");
            dgvAdd.Columns.Add("cname", "Consignee");
            dgvAdd.Columns.Add("phone", "Phone_No");
            dgvAdd.Columns.Add("pin", "Pin_Code");
}

Step 3:

namespace Data_Entry_Application
{
    public partial class Report : Form
    {        
        string uid = "";
        int srows = 0;
        string conn = ConfigurationSettings.AppSettings["constr"];
        public Report()
        {
            InitializeComponent();
            GridDesign();
        }

Step 4:

Convert Excel Button Coding

private void butExcel_Click(object sender, EventArgs e)
{
            dgvAdd.Rows.Clear();
             SqlConnection con = new SqlConnection(conn);
            con.Open();
            if (radioAll.Checked == true)
            {
                string fdate = "";
                string tdate = "";

                string find = "";
                if (radioPall.Checked == true)
                {
                    find = "select DocNo,Consignee,PhoneNo,Pincode from BluStar_Details order by Pincode";
                }
                else if (radioPdate.Checked == true)
                {
                    int year1 = dtpdate1.Value.Date.Year;
                    int month1 = dtpdate1.Value.Date.Month;
                    int day1 = dtpdate1.Value.Date.Day;
                    fdate = datetimeconvert(year1, month1, day1);

                    int year2 = dtpDate2.Value.Date.Year;
                    int month2 = dtpDate2.Value.Date.Month;
                    int day2 = dtpDate2.Value.Date.Day;
                    tdate = datetimeconvert(year2, month2, day2);

                    find = "select DocNo,Consignee,PhoneNo,Pincode from BluStar_Details where (DocDate BETWEEN '" + fdate + "' AND '" + tdate + "') order by Pincode";
                }
                SqlCommand cmd1234 = new SqlCommand(find, con);
                SqlDataReader dr = cmd1234.ExecuteReader();
                while (dr.Read())
                {
                    string val = dr["DocNo"].ToString();
                    string val1 = dr["Consignee"].ToString();
                    string val2 = dr["PhoneNo"].ToString();
                    string val3 = dr["Pincode"].ToString();
                    dgvAdd.Rows.Add(val, val1, val2, val3);
                }
                dr.Close();          


                if (dgvAdd.Rows.Count > 0)
                {
                    Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
                    Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
                    Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
                    app.Visible = true;

                    try
                    {
                        worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];
                        worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
                        worksheet.Name = "Exported from DataGridView";

                        for (int i = 1; i < dgvAdd.Columns.Count + 1; i++)
                        {
                            worksheet.Cells[1, i] = dgvAdd.Columns[i - 1].HeaderText;
                        }

                        for (int i = 0; i < dgvAdd.Rows.Count - 1; i++)
                        {
                            for (int j = 0; j < dgvAdd.Columns.Count; j++)
                            {
                                worksheet.Cells[i + 2, j + 1] = dgvAdd.Rows[i].Cells[j].Value.ToString();
                            }
                        }

                        string fileName = String.Empty;
                        saveFileExcel.Filter = "Excel files |*.xls|All files (*.*)|*.*";
                        saveFileExcel.FilterIndex = 2;
                        saveFileExcel.RestoreDirectory = true;

                        if (saveFileExcel.ShowDialog() == DialogResult.OK)
                        {
                            fileName = saveFileExcel.FileName;

                            workbook.SaveAs(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                        }
                        else
                            return;

                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        app.Quit();
                        workbook = null;
                        app = null;
                    }
                }
                else
                {
                    MessageBox.Show("No Records");
                }

Friday 6 September 2013

Using String Builder to Bulk Insert and Update Data's in Asp.net


//Design gridview
  DataTable dt = new DataTable();
  DataRow dr = null;

  dt.Columns.Add(new DataColumn("CustName"typeof(string)));
  dt.Columns.Add(new DataColumn("CustPosition"typeof(string)));
  dt.Columns.Add(new DataColumn("CustCity"typeof(string)));
  dt.Columns.Add(new DataColumn("CustState"typeof(string)));

  gvCustomer.DataSource = dt;
  gvCustomer.DataBind();


//Add button Insert to gridview
private void Insert()
{ 
      DataTable dt = new DataTable();
      DataRow dr = null;
      dr = dt.NewRow();
      dr["CustName"] = txtName.Text.ToString();
      dr["CustPosition"] = txtPos.Text.ToString();
      dr["CustCity"] = txtCity.Text.ToString();
      dr["CustState"] = txtState.Text.ToString();
      dt.Rows.Add(dr);
      gvCustomer.DataSource = dt;
      gvCustomer.DataBind();
}

//Save button using string builder

 protected void btnSave_Click(object sender, EventArgs e)
 {
   StringBuilder sb = new StringBuilder();
   sb.Append("<root>"); 
   for (int i = 0; i < gvCustomer.Rows.Count; i++)
   {    
    string NamegvCustomer.Rows[i].Cells[0].Text.ToString();
    string Position gvCustomer.Rows[i].Cells[1].Text.ToString();
    string City gvCustomer.Rows[i].Cells[2].Text.ToString();
    string StategvCustomer.Rows[i].Cells[3].Text.ToString();
   
    if(Name != "")
      sb.Append("<row Name='" + Name + "' Position='" + Position + "' City='" +         City + "' State='" + State + "'/>");
   }
   sb.Append("</root>");

  string conStr = WebConfigurationManager.
  ConnectionStrings["BlogConnectionString"].ConnectionString;
  SqlConnection con = new SqlConnection(conStr);
  //InsertCustomer as Stored Procedure
  SqlCommand cmd = new SqlCommand("InsertCustomer", con);
  cmd.CommandType = CommandType.StoredProcedure;
  cmd.Parameters.AddWithValue("@XMLCustomer", sb.ToString());
 try
 {
   using (con)
   {
     con.Open();
     cmd.ExecuteNonQuery();
   }

   lblError.Text = "Record(s) Inserted successfully";
   lblError.ForeColor = System.Drawing.Color.Green;
 }
 catch (Exception ex)
 {
  lblError.Text = "Error Occured";
  lblError.ForeColor = System.Drawing.Color.Red;
  }
 }


//Stored Procedure Insert Query in Sql server
CREATE PROCEDURE [dbo].[InsertCustomer]
(
 @XMLCustomer XML
)
AS
BEGIN

      INSERT INTO CUSTOMER
             (CustName,CustPosition,CustCity,CustState)             
      SELECT
            TempCustomer.Item.value('@Name', 'VARCHAR(50)'),
            TempCustomer.Item.value('@Position', 'VARCHAR(50)'),
            TempCustomer.Item.value('@City', 'VARCHAR(50)'),
            TempCustomer.Item.value('@State', 'VARCHAR(50)')
      FROM @XMLCustomer.nodes('/root/row') AS TempCustomer(Item)

RETURN 0
END

//Upadate button Same Process of Save button differnt stored procedure
//Stored Procedure Update Query in Sql server

CREATE PROCEDURE [dbo].[UpdateCustomer]
(
 @XMLCustomer XML
)
AS
BEGIN

      UPDATE Customer
            SET CustName=TempCustomer.Item.value('@Name', 'VARCHAR(50)'),
            CustPosition=TempCustomer.Item.value('@Position', 'VARCHAR(50)'),
            CustCity=TempCustomer.Item.value('@City', 'VARCHAR(50)'),
            CustState=TempCustomer.Item.value('@State', 'VARCHAR(50)')
      FROM @XMLCustomer.nodes('/root/row') AS TempCustomer(Item)
      WHERE CustID=TempCustomer.Item.value('@CustID', 'INT')

RETURN 0
END