error:{"Procedure or function 'insertEmp' expects parameter '@Sal', which was not supplied."}
this is my stored procedure
create PROCEDURE insertEmp(@Id int output,@Name varchar(50),@Sal money) AS
begin
insert into EMP1(Empname,EmpSalary)values (@Name,@Sal)
select @Id=@@Identity
END
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 SP2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(helpercs.connectionstring);
SqlCommand cmd = new SqlCommand("insertEmp", con);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter parId, parName, parSalary;
parId = cmd.Parameters.Add("@Id", SqlDbType.Int);
parId.Direction = ParameterDirection.Output;
parName = cmd.Parameters.Add("@name",SqlDbType.VarChar,50);
parSalary = cmd.Parameters.Add("@salary",SqlDbType.Money);
parName.Value =int.Parse(txtname.Text);
parSalary.Value =int.Parse( txtsalary.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
txtid.Text = parId.Value.ToString();
}
}
}
plz help me i tried for about 2hours