Guest User

Guest User

  • Tech Writer
  • 189
  • 25k

Cannot implicitly convert type 'void' to 'string'

May 23 2018 2:24 AM
BAL.cs
  1. public void Delete(string id)  
  2.       {  
  3.           cmd = new MySqlCommand("DeleteProduct", con);  
  4.           cmd.CommandType = CommandType.StoredProcedure;  
  5.           cmd.Parameters.AddWithValue("in_ProductId", id);  
  6.           con.Open();  
  7.           int i = cmd.ExecuteNonQuery();  
  8.           con.Close();  
  9.       }  
Home Controller
  1. public ActionResult DeleteProduct(string id)  
  2.        {  
  3.   
  4.            try  
  5.            {  
  6.                BAL objBAL = new BAL();  
  7.                string product = objBAL.Delete(id); //error  
  8.                if (product != null)  
  9.                {  
  10.                  Response.Write("<script>alert('Data Deleted Successfully')</script>");  
  11.                }  
  12.                
  13.            }  
  14.            catch (Exception ex)  
  15.            {  
  16.                throw ex;  
  17.            }    
  18.        }  
 

Answers (1)