Error while updating data using data adapter
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ADO_DataSet_Prac
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        DataSet ds = new DataSet();
        SqlDataAdapter da;
        DataTable dt;

        private void Form1_Load(object sender, EventArgs e)
        { 
            SqlConnection con = new SqlConnection("Server = localhost; Database = MSNETDB; Integrated Security=True;MultipleActiveResultSets=True");
             da = new SqlDataAdapter("Select * from Emp",con);
             da.Fill(ds, "Emp");
             dt=ds.Tables["Emp"];
             gvEmp.DataSource = dt;

           //Insert command for data adapter
            SqlCommand cmdInsert = new SqlCommand("Insert into Emp(EmpName,EmpSalary) Values(@Name,@Salary)", con);
            SqlParameter Name = cmdInsert.Parameters.Add("@Name", SqlDbType.VarChar, 100);
            SqlParameter Salary = cmdInsert.Parameters.Add("@Salary", SqlDbType.Money);
            Name.SourceColumn = "EmpName";
            Salary.SourceColumn = "EmpSalary";
            da.InsertCommand = cmdInsert;

            //Update command for data adapter
            SqlCommand cmdUpdate = new SqlCommand("Update Emp set EmpName =@Name, EmpSalary =@Salary where EmpId=@Id", con);
            SqlParameter Id = cmdUpdate.Parameters.Add("@Id", SqlDbType.Int);
            Name.SourceColumn = "EmpName";
            Salary.SourceColumn = "EmpSalary";
            Id.SourceColumn = "EmpId";
            da.UpdateCommand = cmdUpdate;
}
 private void btnDa_Update_Click(object sender, EventArgs e)
        {
            da.Update(ds,"Emp"); //Exception throw here
        }
    }
}
</code></pre>

<p>While trying to update, I get a <code>SqlException</code> saying: </p>

<blockquote>
  <p><em>Must declare the scalar variable "@Name".</em></p>
</blockquote>

<p>The exception is thrown on </p>

<pre><code>da.update(ds,"Emp") 
</code></pre>

<p>method of data adapter. I don't know what is the reason. I checked all my syntax and errors and everything looks fine but still it is throwing error. I tried with break point as well but with no luck.</p>
