public string update(childUpdater child) { string response = "Error"; try { SqlConnection con = new SqlConnection(data); SqlCommand cmd = new SqlCommand("UPDATE courseChild SET name = @name WHERE childId = @childId AND parentId = @parentId", con); cmd.Parameters.AddWithValue("@name", child.name); cmd.Parameters.AddWithValue("@childId", child.childId); cmd.Parameters.AddWithValue("@parentId", child.parentId); con.Open(); response = cmd.ExecuteNonQuery().ToString(); con.Close(); } catch (SqlException ex) { return(ex.ToString()); } catch { return(response); } return("Success"); }
public string updateString(string childId, string name, string user, string parentId) { if (childId == null || childId.Length <= 0) { return("childId Null"); } if (name == null || name.Length <= 0) { return("name Null"); } if (user == null || user.Length <= 0) { return("userId Null"); } if (parentId == null || parentId.Length <= 0) { return("parentId Null"); } string response = "Error"; try { childUpdater chil = new childUpdater(); chil.childId = new Guid(childId); chil.name = name; chil.userId = new Guid(user); chil.parentId = new Guid(parentId); response = update(chil); } catch { } return(response); }