sangeetha k

sangeetha k

  • NA
  • 207
  • 51.3k

Sql exception caught correct me where iam going wrong

Sep 25 2017 4:06 AM
Procedure or function 'spDATA_UPDATE' expects parameter '@Phone', which was not supplied. 
 
#database procedure
alter PROCEDURE [dbo].[spDATA_UPDATE]
@Phone as bigint,
@address as varchar(20),
@email_id as varchar(20)
AS
BEGIN
UPDATE Customer08_Details SET address=@address,email_id=@email_id , Phone=@Phone
END
GO
 
# dataacess layer
try
{
SqlConnection conn = new SqlConnection(constring);
conn.Open();
SqlCommand cmd = new SqlCommand("spDATA_UPDATE", conn);
cmd.Parameters.AddWithValue("@Phone", DbType.Int64).Value = Phone;
cmd.Parameters.AddWithValue("@email_id", DbType.String).Value = email_id;
cmd.Parameters.AddWithValue("@address", DbType.String).Value = Address;
adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return dt;
}
 
# business logic layer
 
 
public DataTable updateCustomerDetai(Int64 Phone, string email_id, string address)
{
DataTable dt = new DataTable();
dt = dal.updateCustomerDetails(Phone, email_id, address);
return dt;
}
#code behind of grid view
 
 
 
 
protected void gridView_Rowupdating(object sender,GridViewUpdateEventArgs e)
{
DataTable dt = new DataTable();
TextBox phone_no = gridView.Rows[e.RowIndex].FindControl("txtPhone") as TextBox;
long Phone = Convert.ToInt64(phone_no.Text);
TextBox Address = gridView.Rows[e.RowIndex].FindControl("txtAddress") as TextBox;
string address = Address.Text;
TextBox Email = gridView.Rows[e.RowIndex].FindControl("txtEmail") as TextBox;
string Email_id = Email.Text;
dt = bal.updateCustomerDetai(Phone, Email_id, address);
}
 
 

Answers (2)