When a form is being submitted, I need to check if a duplicate already exists. If it does, it stops the form from being submitted and allows the person to edit the fields again. I have never really used ajax before, but I have read that for something like this, it would be the best to use. I also can not use PHP, but can use javascript and asp. Right now, I am able to check the database if duplicate values already exist by doing the following:
var SQL = " SELECT COUNT(LeaveID) AS Dup, personalID, StartDate, EndDate, StartTime, EndTime, LeaveType";
SQL += " FROM onLeave";
SQL += " WHERE personalID = " + ipersonalID;
SQL += " GROUP BY personalID, StartDate, EndDate, StartTime, EndTime, LeaveType";
SQL += " HAVING COUNT(LeaveID) > 1";
SQL += " ORDER BY StartDate DESC";
var rs = Connection.Execute(SQL);
writeTable(rs)
writetable(rs) just outputs the data into a html table and ipersonalID is the current ID of the person viewing the page. The submit is just a simple input like below:
<input type="button" name="btnSubmit" value="Submit" onclick="submitSkedChange()" id="btnSubmit"/>
ALTER TABLE onLeave ADD CONSTAINT uc_leave UNIQUE(personalID, StartDate, EndDate, StartTime, EndTime, LeaveType)