0
Die INSERT-Anweisung in Konflikt mit der FOREIGN KEY-Einschränkung „FK_CustomizedReportProducts_CustomizedReportSections“ einfügen drücken. Der Konflikt ist in der Datenbank "LarvolDelta", Tabelle "dbo.CustomizedReportSections", Spalte "customized_report_section_id" aufgetreten.
Code
$('#btnProducts').click(function() {
debugger;
var itemId = $(".prodId").val();
var productid = $(".prodId").val();
if (itemId == '') return;
var itemValue = $(".prodName").val();
var treeHtml = "";
var sectionid = '00000000-0000-0000-0000-000000000000';
var commentRegion = "";
var sectionText = $("#txtProducts").val();
if (sectionText == "")
return;
var itemFound = false;
var ProductRatingRegion = "";
ProductRatingRegion += "<div id='dialogPIR" + itemId + "' class='dialogPIR' title='<%=lblPIRCaption%>" + " for " + itemValue + "' style='display:none'>";
ProductRatingRegion += "<span id='spanPIR" + itemId + "'></span>";
ProductRatingRegion += "<div style='text-align:left;margin-top: 20px;'>";
ProductRatingRegion += "<div style='z-index:1;' id='PIRSlider' name='PIRSlider' class='PIRSlider" + itemId + "'></div><br/>";
ProductRatingRegion += "<div class='steps' style='width: 216px; height: 40px; margin-left:-1px; margin-top: -25px; color: gray; z-index:0;'>";
ProductRatingRegion += "<span style='width:6px; left:0%;'>|<br />NA</span>";
ProductRatingRegion += "<span style='left:10%;'>|<br />1</span>";
ProductRatingRegion += "<span style='left:20%;'>|<br />2</span>";
ProductRatingRegion += "<span style='left:30%;'>|<br />3</span>";
ProductRatingRegion += "<span style='left:40%;'>|<br />4</span>";
ProductRatingRegion += "<span style='left:50%;'>|<br />5</span>";
ProductRatingRegion += "<span style='left:60%;'>|<br />6</span>";
ProductRatingRegion += "<span style='left:70%;'>|<br />7</span>";
ProductRatingRegion += "<span style='left:80%;'>|<br />8</span>";
ProductRatingRegion += "<span style='left:90%;'>|<br />9</span>";
ProductRatingRegion += "<span style='left:100%;'>|<br />10</span>";
ProductRatingRegion += "</div>";
ProductRatingRegion += "<input type='button' value='<%=lblPIRButtonText%>' onclick='PIRAddedHandler(\"" + itemId + "\")'/>";
ProductRatingRegion += "</div>";
ProductRatingRegion += "</div>";
commentRegion += "<div id='dialog" + itemId + "' class='dialog' title='Middle Column for " + itemValue + "' style='display:none'>";
commentRegion += "<span id='spanComments" + itemId + "'></span>";
commentRegion += "<p style='text-align:left;margin-top: 20px;'>";
commentRegion += "<textarea id='newComment' name='comments' class='commentInputBox" + itemId + "' cols='55' rows='3'>Enter your comments here...</textarea><br/>";
commentRegion += "<input type='button' value='Add Middle Column' onclick='commentAddedHandler(\"" + itemId + "\")'/>";
commentRegion += "</p>";
commentRegion += "</div>";
treeHtml += '<li><img src="../../Images/Icons/Cross.png" style="cursor:pointer; float:left; width:14px; margin-right:4px;" onclick="DeleteCurrentLi(this)";/><span class="file product_element" id="' + itemId + '"> ' + sectionText + '</span>' + " "
treeHtml += '<img src="../../Images/Icons/comments.png" title="Middle Column" class="commentsIcon" onclick="commentIconClickHandler(\'' + itemId + '\')"/>' + " "
treeHtml += '<img src="../../Images/Icons/PIRIcon.png" title="<%=lblPIRCaption%>" class="PIRIcon" product_id="' + itemId + '" id="pir_icon' + itemId + '" />'
+ '<ul class="selectable">';
treeHtml += '</ul></li>';
$("ul#productTreeview").sortable({
revert: false
});
// $("ul, li").disableSelection();
$("ul#productTreeview li").draggable({
appendTo: "body",
helper: "clone",
});
var key, value;
if (li.length === 0) {
$("ul#productTreeview").append(treeHtml + commentRegion + ProductRatingRegion);
var itemId = sectionText;
li.push(itemId);
}
else {
for (key in li) {
if (li.hasOwnProperty(key) && !isNaN(parseInt(key, 10))) {
value = li[key];
if (value.substring() === sectionText)
itemFound = true;
}
}
if (itemFound == true) {
// alert('item already present');
ShowPopup($('#dialog').dialog('open'));
}
else {
$("ul#productTreeview").append(treeHtml + commentRegion + ProductRatingRegion);
var itemId = sectionText;
li.push(itemId);
}
}
$("#txtProducts").val("");
SaveCustomizedRecord(productid, reportId, sectionid);
});
});
Vermutung: SaveCustomizedRecord() erzeugt irgendwie einen Fremdschlüsselbeschränkungsfehler. Sie scheinen einige Berichte oder so zu fehlen - überprüfen Sie Ihre Rohdaten und vergleichen Sie mit was auch immer Ihre Rohdateneingabe zu SaveCustomizedRecord ist - überprüfen Sie insbesondere, ob die IDs in Ihren Tabellen vorhanden sind. Ohne deine Speichermethode und deinen Tischinhalt sieht es so aus, als würdest du in einen Kristallball schauen und raten. –
Ich möchte eine Webmethode auf Knopf klicken, wie kann ich dies tun –