I have this piece of code in a class (DataBase) and I’m getting
Not all Paths return a Value.
Any help will be really appreciated.
public static DataSet DELETE_PDT(String rowid)
{
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand("sp_DELETE_PDT", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@rowid", SqlDbType.Int).Value = rowid;
con.ConnectionString = ConfigurationManager.ConnectionStrings["WMS"].ConnectionString;
try
{
con.Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
}
catch (Exception ex)
{
throw new Exception("Error while deleting record. Please contact your System Administrator", ex);
}
}
Your method should have a
return valuebecause you have declared it to returnDataset.example,
if you don’t want to see the error message, change
to
UPDATE 1
based on your comments, I’ll modifed it to return a string value again.