HOME

Wednesday, February 29, 2012

About Coffee Script


CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.
The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings, will work in every JavaScript implementation, and tends to run as fast or faster than the equivalent handwritten JavaScript.

Execute c# program in notepad and cmd? with out visual studio

Introduction
In this article you will learn to write your first C# program and compile it using the command-line C# compiler. I strongly recommend you read this article first to correctly install the .NET v1.1 SDK on your computer. The goal of this article is to get you comfortable with writing a C# program and compiling it. The code you type will be explained in later articles. So dont worry if you cant understand any code in this article.

As tradition goes the first program though is the Hello World program, which does nothing more but print a simple "Hello World" message on the console screen. Youll need a text editor (like Notepad) and the .NET v1.1 SDK installed on your computer to work with this example.
Let's begin!
Step 1: Start notepad from Start -> Program Files -> Accessories -> Notepad so that you can write the Hello World program. The program you write in C# is also called as source code.
Step 2: Write the Hello World program, you can either type the program shown below into notepad or just copy-paste it from this article.
/*
 HelloWorld.cs - First C# Program
 Written by - Saurabh Nandu
 Compilation:
 csc HelloWorld.cs
*/

public class HelloWorld
{
  public static void Main()
  {
    //Print Hello World
    System.Console.WriteLine("Hello World !");
  }
}
Note 1: C# is a case-sensitive language hence in C# class HelloWorld, class helloWorld and class helloworld are treated differently, so be very careful while typing and type exactly as shown !!
Note 2: Indenting (leaving spaces before each line), is not mandatory, but its a good practice since it makes it easier to read indented code.
Step 3: Once you have finished typing your program you should Save the source code file. In fact after making any changes to your source code, you should always save the file. To save the file for the first time in notepad click on
File menu -> Save As. In the Save As dialog select the directory from the Save In dropdown where you want to save your files, I generally save my files to C:\csharp, and then in the File name textbox, enter the file name as HelloWorld.cs (although you can provide any name you want but it should have an extension .cs). and click Save. Once you have saved the source code, and if you make any further modifications, in notepad use the Ctrl+S keyboard short-cut to save your source code file.
 

Figure 1: Notepad Save As dialog
Note 3: C# source code files are stored with the extension .cs.
Note 4: In notepad's Save As dialog, File name textbox, always enter the file name in quotes (" ") so that the file is saved with the correct *.cs extension, else on some operating systems if you miss the quotes the file is saved with the extension *.txt (default for text files) due to which your files may not compile.
Step 4: Since you have finished writing the source code its time to compile it. Since we are using a command-line compiler that ships with the .NET SDK, start the command prompt fromStart -> Program Files -> Accessories -> Command Prompt. Or go to Start -> Run, type cmd and press enter.
Note 5: If you have installed Visual Studio.NET then start the command prompt from Start -> Program Files -> Microsoft Visual Studio .NET -> Visual Studio .NET Tools -> Visual Studio .NET Command Prompt. We use this prompt since it has the correct path settings for the C# compiler. Refer to the Installing the .NET v1.1 SDK article for more information on setting paths.
Now from the command prompt navigate to the directory where you have stored the source code file by issuing the following DOS commands.

cd\ - To navigate to the root of the drive
cd csharp - To navigate to the csharp directory.

Once you are in the csharp directory where you saved the source code file earlier, its time to run the C# Compiler csc.exe. Issue the following command to compile our HelloWorld.csprogram:

csc HelloWorld.cs 

You should see the output similar to that shown in figure below indicating the file was successfully compiled.
 
Figure 2: Compilation of C# source code
Step 5: If the compilation of the source code was successful then a new executable (Exe) file by the name HelloWorld.exe will be created in the directory you compiled the source code.
To execute the program simply type the name of the executable file at the command prompt and you will see the output of the program (Hello World !) as shown below.

Figure 3: Executing Hello World application
Congratulations you have successfully compiled your first C# program! Its time for you to proceed further and learn the C# language.
Points to Remember
1) C# code can be written in any text editor like notepad.
2) C# Source Code files are saved with the extension .cs.
3) C# is a case-sensitive language so you have to be careful while typing.
4) C# runs on the .NET Platform, hence you need to install the .NET SDK in order to compile C# programs.
5) The C# compiler is contained within the file csc.exe, which generally resides in the C:\windows\Microsoft.NET\Framework\v1.0.4322 directory.

View State Problem in Asp.Net

 ASP.NET view state, in a nutshell, is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks. In my experiences as a trainer and consultant, view state has caused the most confusion among ASP.NET developers. When creating custom server controls or doing more advanced page techniques, not having a solid grasp of what view state is and how it works can come back to bite you. Web designers who are focused on creating low-bandwidth, streamlined pages oftentimes find themselves frustrated with view state, as well. The view state of a page is, by default, placed in a hidden form field named __VIEWSTATE. This hidden form field can easily get very large, on the order of tens of kilobytes. Not only does the __VIEWSTATE form field cause slower downloads, but, whenever the user posts back the Web page, the contents of this hidden form field must be posted back in the HTTP request, thereby lengthening the request time


The load view state stage only happens when the page has been posted back. During this stage, the view state data that had been saved from the previous page visit is loaded and recursively populated into the control hierarchy of the Page. It is during this stage that the view state is validated. As we'll discuss later in this article, the view state can become invalid due to a number of reasons, such as view state tampering, and injecting dynamic controls into the middle of the control hierarchy.


 site has been written in asp.net and as such has a hidden input field with the id "__viewstate". As the user goes through the site this string becomes longer and longer and when I look in the page source the most important part, the content, is underneath all this unwanted code.

Saturday, February 25, 2012

Convert currency number to words Indian currency or foreign currency

Step 1. download this class file MultiCurrency.cs

Step 2. Paste To your Project

Step 3.Use this code where you need to convert
           
            MultiCurrency currenc = new MultiCurrency(Criteria.Indian); \\Set here currency type
            string number = "123.45"\\Your amount set here
            string[] ss = number.Split('.');
            if (ss.Length == 1)
            {
                number = number + ".00";
            }
            string[] amount = number.Split('.');
            string AmountInWords = currenc.ConvertToWord(amount[0]);
            string paises;
            AmountInWords = AmountInWords + " Rupees";
            if (int.Parse(amount[1]) == 0)
            {
                amount[1] = "00";
                paises = "";
            }
            else
            {
                paises = currenc.ConvertToWord(amount[1]);
                paises = " And " + paises + " Paises";
            }




        AmountInWords =AmountInWords +paises ;

Friday, February 24, 2012

Set Printer defalut Font, font size, linespacing and letter spacing in JavaScript and ASP.NET


 function getPrint() {
   
        pp = window.open(); //Adding HTML opening tag with <HEAD> … </HEAD> portion
        pp.document.writeln('<HTML><HEAD><title>Issue Voucher</title>');
        pp.document.writeln('<base target="_self"></HEAD>'); //Adding Body Tag
        pp.document.writeln('<body bottomMargin="0"');
        pp.document.writeln('leftMargin="0" topMargin="0" rightMargin="0" >');
        pp.document.writeln('<form>'); //Creating two buttons Print and Close within a HTML table
        pp.document.writeln('<p id="par">');
     
        pp.document.writeln(document.getElementById('<%=DivPrint.ClientID %>').outerHTML);
//Ending Tag of
 </form>, </body> and </HTML>
     
        //Adding form Tag

        pp.document.writeln('</p>');

        for (i = 0; i < pp.document.all.length; i++) {
            pp.document.all[i].style.fontFamily = "Lucida Console,Script";
            pp.document.all[i].style.fontSize = 10;
            pp.document.all[i].style.lineHeight = 1.5;
            pp.document.all[i].style.fontStyle = "normal";
            pp.document.all[i].style.letterSpacing = "5px";
        }

        pp.document.writeln('</form></body></HTML>');

        pp.document.close();
        pp.focus();
        pp.print();
     
    }


where DivPrint is replace with your Print area

Thursday, February 23, 2012

Remove the URL and Date Time on Printed Page

Step 1. Open Internet Explorer File --> Page Setup..


Step 2.Click Page Setup and Empty the Hesder and Footer Options
   

Create Dynamic table C# asp.net


// code for .aspx page
  <asp:Panel  ID="panpage" runat="server">
   
    </asp:Panel>


// code in aspx.cs page


              Table tbl = new Table();
                tbl.Attributes.Add("border", "0");
                tbl.Attributes.Add("border-color", "Green");
                tbl.Attributes.Add("width", "100%");
                tbl.Attributes.Add("cellpadding", "0");
                tbl.Attributes.Add("cellspacing", "0");
                tbl.Attributes.Add("class", "lblbirthday1");

                panpage.Controls.Add(tbl);
                TableRow tr = new TableRow();
                TableCell tc = new TableCell();
                tc.Attributes.Add("width", "100%");
             
                tc.Attributes.Add("align", "Left");
                tc.Attributes.Add("valign", "top");

                Label name = new Label();
                name.Text = "<font color='block'> " + arrStr1.Replace("@", "<br />") + "</font><br/><font                             color='blue'>-----------------------------------</font>";
                tc.Controls.Add(name);

                tr.Cells.Add(tc);
                tbl.Rows.Add(tr);
                panpage.Controls.Add(tbl);


Send Mail to Internal Microsoft Office Outlook mail from C# Asp.Net



  public void SendMail(string From,string TO,string Subj,string msg)
    {

     
        string strFrom = From, strTo = TO, strSubject = Subj, strMsg = msg;


        // Create the mail message
        MailMessage objMailMsg = new MailMessage(strFrom, strTo);

        //objMailMsg.BodyEncoding  Encoding.UTF8;
        objMailMsg.Subject = strSubject;
        objMailMsg.Body = strMsg;
        objMailMsg.Priority = MailPriority.High;
        objMailMsg.IsBodyHtml = true;

        //prepare to send mail via SMTP transport
        SmtpClient objSMTPClient = new SmtpClient();
        objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
        objSMTPClient.Send(objMailMsg);

    }

Send mail to gmail from C# and Asp.Net

---------------Code in .CS ---------------

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


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

MailMessage mail = new MailMessage();
mail.To.Add("xxx@gmail.com"t);  // To Mail ID
mail.From = new MailAddress("yyy@gmail.com");  // From Mail ID
mail.Subject = "Welcome To NL SOFTTECH SERVICES!!";
string Body = "body content";
mail.Body = Body;
mail.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["SMTP"];
smtp.Credentials = new      System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], ConfigurationManager.AppSettings["FROMPWD"]);
smtp.EnableSsl = true;
smtp.Send(mail);




--------------webconfig file-------------------------

<appSettings>
    <add key="SMTP" value="smtp.gmail.com"/>
    <add key="FROMEMAIL" value="yyy@gmail.com"/>
    <add key="FROMPWD" value="Password of yyy@gmail.com"/>
  </appSettings>

Generating Random Number and String in C#


The Random class defined in the .NET Framework class library provides functionality to generate random numbers.

The Random class constructors have two overloaded forms. It takes either no value or it takes a seed value.

The Random class has three public methods - Next, NextBytes, and NextDouble. The Next method returns a random number, NextBytes returns an array of bytes filled with random numbers, and NextDouble returns a random number between 0.0 and 1.0. The Next method has three overloaded forms and allows you to set the minimum and maximum range of the random number.

The following code returns a random number:

int num = random.Next();

The following code returns a random number less than 1000.

int num = random.Next(1000);

The following code returns a random number between min and max:


private int RandomNumber(int min, int max)
{
Random random = 
new Random();return random.Next(min, max);
}

At some point, you may also want to generate random strings. I have created a method, which takes first parameter as the size of string and second parameter if you want the string to be lowercase.
/// <summary>/// Generates a random string with the given length/// </summary>/// <param name="size">Size of the string</param>/// <param name="lowerCase">If true, generate lowercase string</param>/// <returns>Random string</returns>private string RandomString(int size, bool lowerCase)
{
StringBuilder builder = 
new StringBuilder();
Random random = 
new Random();char ch ;for(int i=0; i<size; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
builder.Append(ch);
}
if(lowerCase)return builder.ToString().ToLower();return builder.ToString();
}

You can even combine the two methods - RandomNumber and RandomString to generate a combination of random string and numbers. For example, the following code generates a password of length 10 with first 4 letters lowercase, next 4 letters numbers, and last 2 letters as uppercase.

public string GetPassword()
{
StringBuilder builder = 
new StringBuilder();
builder.Append(RandomString(4, 
true));
builder.Append(RandomNumber(1000, 9999));
builder.Append(RandomString(2, 
false));return builder.ToString();
}

Wednesday, February 22, 2012

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. ASP.NET

are you using SQL DataReader ?? if yes check are you closing the data reader.


(OR)



This typically happens when connections are not closed after they are used.
I think you need to check how many open connections you have while the application is running.

Thursday, February 16, 2012

Encrypt and Decrypt in C# asp.net


public String Encrypt(String code)
        {
            byte[] encData_byte = new byte[code.Length];
            encData_byte = System.Text.Encoding.UTF8.GetBytes(code);
            return Convert.ToBase64String(encData_byte);

        }
        public String Decrypt(String code)
        {
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(code);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            char[] decoded_char = new char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);

            return new String(decoded_char);

            //string result = new String(decoded_char);

            //            Label1.Text = "Decoded :" + result;

        }

Reading HTML controls from server side page .aspx.cs c#

string username; string password; username= String.Format("{0}", Request.Form["uid"]); password = String.Format("{0}", Request.Form["pwd"]); where uid & pwd are textboxes ids

Bulk insert and update from gridview using Asp.net and C#

This is how to insert bulk records. More a less, its same only, But some what difference. As in bulk update we fetch
records and display in grid. But in bulk insert, we have to first create an empty row for inserting bulk records.

Download source and store procedure script from here.

private void InsertEmptyRow()
{
  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)));

  for (int i = 0; i < 5; i++)
  {
      dr = dt.NewRow();
      dr["CustName"] = string.Empty;
      dr["CustPosition"] = string.Empty;
      dr["CustCity"] = string.Empty;
      dr["CustState"] = string.Empty;
      dt.Rows.Add(dr);
   }

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

As, you see above code I am creating five empty rows initially which is empty. This method I am calling at page load event.

Note :- I am creating only five empty rows, you can create as much required for your bulk insert according to your
 requirement

And one more difference between, Bulk update and bulk insert is that as we fetch all records for bulk update, so we
don’t have empty rows, but in insert we have five empty rows. One more thing, Suppose we insert three rows and two
 rows empty what would happen ?. For that I am checking if name field is empty or not, else don’t insert.

StringBuilder sb = new StringBuilder();
 sb.Append("<root>"); 
 for (int i = 0; i < gvCustomer.Rows.Count; i++)
 {
    TextBox txtName = gvCustomer.Rows[i].FindControl("txtName"as TextBox;
    TextBox txtPosition = gvCustomer.Rows[i].FindControl("txtPosition"as TextBox;
    TextBox txtCity = gvCustomer.Rows[i].FindControl("txtCity"as TextBox;
    TextBox txtState = gvCustomer.Rows[i].FindControl("txtState"as TextBox;

    if(txtName.Text.Length != 0)
      sb.Append("<row Name='" + txtName.Text.Trim() + "' Position='" + txtPosition.Text.Trim() +
         "' City='" + txtCity.Text.Trim() + "' State='" + txtState.Text.Trim() + "'/>");
 }
 sb.Append("</root>");

As you see, I am checking txtName if length is more then zero then insert record else skip it.  As other insert detail is simple.

string conStr = WebConfigurationManager.
ConnectionStrings["BlogConnectionString"].ConnectionString;
 SqlConnection con = new SqlConnection(conStr);
 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;
  }

Store procedure also simple, just direct insert from XML structure what it consist, this is also difference between bulk update
 as in which we check in where condition of customer id matches or not

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

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

Note :-  In bulk update, we are passing customer id also, here its not required as it is auto increment.


Bulk Update using Gridview and

 Sql Server XML

As we are know importance of opening and closing connection while using Database. Generally when we have
 some many records into database and have to update all record at same time, opening and closing
 connection for each transaction will give performance issue.

For this, we like to do an bulk update for all records, instead of single records. When we update record into
 bulk, its open only one connection. Here, in this article I will explain how to do bulk update using gridview
and sql server xml. I will pass an XML from code behind and using in store procedure. In SP, I will use
 XML as data type. and will update into table.

Download source code and SP script here.

I will use Template column in Gridview.  Template column, use Textbox control to display all records. Records
are binding using Sql Data Source.  A button has been used, for updating bulk records. Using Sql Server XML,
 I had learned from here.

HTML mark up look like below :-
<asp:GridView ID="gvCustomer" runat="server" AutoGenerateColumns="False" BackColor="White"
 BorderColor="#999999" BorderWidth="1px" CellPadding="3" DataKeyNames="CustID"DataSourceID="SqlDataSource1" GridLines="Vertical" BorderStyle="None" ShowFooter="True">
   <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
     <Columns>
        <asp:BoundField DataField="CustID" HeaderText="CustID" InsertVisible="False" ReadOnly="True"SortExpression="CustID" />
        <asp:TemplateField HeaderText="Name" SortExpression="CustName">
            <ItemTemplate>
                <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("CustName") %>' BorderStyle="Solid"BorderWidth="1px"/>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Position" SortExpression="CustPosition">
            <ItemTemplate>
               <asp:TextBox ID="txtPosition" runat="server" Text='<%# Bind("CustPosition") %>'BorderStyle="Solid" BorderWidth="1px"/>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="City" SortExpression="CustCity">
            <ItemTemplate>
               <asp:TextBox ID="txtCity" runat="server" Text='<%# Bind("CustCity") %>' BorderStyle="Solid"BorderWidth="1px"/>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="State" SortExpression="CustState">
            <ItemTemplate>
              <asp:TextBox ID="txtState" runat="server" Text='<%# Bind("CustState") %>' BorderStyle="Solid"BorderWidth="1px"/>
            </ItemTemplate>
        </asp:TemplateField>
      </Columns>
      <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
      <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
      <SelectedRowStyle BackColor="#008A8C" ForeColor="White" Font-Bold="True" />
      <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
      <AlternatingRowStyle BackColor="#DCDCDC" />
      </asp:GridView>

      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BlogConnectionString %>"
           SelectCommand="SELECT * FROM [Customer]"></asp:SqlDataSource>
       <div align="center" style="width500px">
          <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" />
          <br />
          <br />
       <asp:Label ID="lblError" runat="server"></asp:Label>
        </div>

I had created an function named UpdateCustomer, what it will do is first iterate all gridview rows and append in stringbuilder object ,
 which it will create an XML structure

StringBuilder sb = new StringBuilder();
       
sb.Append("<root>");

for (int i = 0; i < gvCustomer.Rows.Count; i++)
{
   string CustID = gvCustomer.Rows[i].Cells[0].Text;

   TextBox txtName = gvCustomer.Rows[i].FindControl("txtName"as TextBox;
   TextBox txtPosition = gvCustomer.Rows[i].FindControl("txtPosition"as TextBox;
   TextBox txtCity = gvCustomer.Rows[i].FindControl("txtCity"as TextBox;
   TextBox txtState = gvCustomer.Rows[i].FindControl("txtState"as TextBox;

   sb.Append("<row CustID='" + CustID + "' Name='" + txtName.Text.Trim() + "' Position='" + txtPosition.Text.Trim() +
             "' City='" + txtCity.Text.Trim() + "' State='" + txtState.Text.Trim() + "'/>");
}
sb.Append("</root>");

Then, I will call usual Sql Connection, Sql Command, pass parameter to database.

string conStr = WebConfigurationManager.
ConnectionStrings["BlogConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(conStr);
SqlCommand cmd = new SqlCommand("UpdateCustomer", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@XMLCustomer", sb.ToString());

try
{
  using (con)
  {
    con.Open();
    cmd.ExecuteNonQuery();
  }

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

As mentioned above, I am passing string builder object in XML structure to store procedure. I had created UpdateCustomer store procedure,
which mark up looks like below one :-

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER 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


As mentioned above code, parameter has an XML data type. Which will update customer table from temporary table created from XML.