hai this is hari, i create sp in following format.
ALTER procedure [spInsertEmp]
@empName varchar(50),
@Emp_Id int ,
@option varchar(10)
as
set nocount off
IF @option='delete'
delete from emp where Emp_Id=@Emp_Id
if @option='insert'
IF EXISTS(select EmpName from emp where EmpName=@empName)
return -1
ELSE
insert into emp (EmpName)values(@empName)
if @option='update'
begin
UPDATE emp set Empname=@empname where Emp_Id=@Emp_Id
End
inthat i gave codebehind using c# like below format
protected void btnupdate_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server = MYLAPTOP;uid=sa;pwd =hari_123; database =test1");
//conn.Open();
SqlCommand cmd = new SqlCommand("spInsertEmp", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@empName", SqlDbType.VarChar, 50).Value = txtAdditionalChargeType.Text;
cmd.Parameters.Add("@Emp_Id", SqlDbType.Int).Value =Convert.ToInt32(txtAdditionalChargeType1.Text);
cmd.Parameters.Add("@option", SqlDbType.VarChar, 10).Value = "update";
inthat i got error for this line
cmd.Parameters.Add("@Emp_Id", SqlDbType.Int).Value =Convert.ToInt32(txtAdditionalChargeType1.Text);
The error was input string was not in a correct format
So any one help me to give the update button code belongs this above sp. Please help me.
thanks hari