Click to See Complete Forum and Search --> : Capture Record, Run Proc, with Javascript Confirm


baldwingrand
11-06-2008, 10:42 AM
I have a stored proc that is working well in SQL Server 2005 on its own. It's not working in my web page though. (Code below.) My goal was to capture the relevant record in Javascript using a confirm statement, then submit the form and run the proc. But I get this error: "Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record." So, I'm not capture the record correctly, but not sure how to capture it correctly. Any help is appreciated. Thanks.


--SQL PROC
spFRRequestReassign

@vExpertID int,
@vRequestRecID int

AS

BEGIN TRAN
Declare @vOldExpertID int

Select @vOldExpertID = ExpertID From FRRequest
Where RequestRecID = @vRequestRecID

Insert Into FRRequestHistory (RequestRecID, UpdateDate, ChangeType, NewValue, OldValue)
Values (@vRequestRecID, getDate(), 'Expert Reassigned', @vExpertID, @vOldExpertID)

Update FRRequest
Set ExpertID = @vExpertID
Where RequestRecID = @vRequestRecID
COMMIT TRAN

---------------------

'ASP SECTION
If Request.Form("cboExpertID") <> "" Then
vExpertID = stripquotes(Request.Form("cboExpertID"))

vSQLReassign = "spFRRequestReassign "
vSQLReassign = vSQLReassign & "@vExpertID = '" & vExpertID & "', "
vSQLReassign = vSQLReassign & "@vRequestRecID = '" & vCaseNumber & "'"

CN.Execute (vSQLReassign)

End If

--------------------------------

<!-- HTML SECTION -->

<select name="cboExpertID" id="cboExpertID">
<option></option>
<%
'Select experts and limit the number of cases experts are allowed.
Set RS = CN.Execute ("spFRSelectExperts '" & vAreaExpertiseID & "'")
If Not RS.EOF Then
Do While Not RS.EOF
'IsMaxedOut is the column that stores whether or not a particular expert has exceeded the maximum cases allowed.
If RS.Fields("IsMaxedOut") = 1 Then
%>
<option value='-1' disabled <%If vAreaExpertiseID = stripquotes(RS.Fields("AreaExpertiseID")) Then Response.Write "selected" %>><%= RS.Fields("ExpertLastName")%>, &nbsp;<%= RS.Fields("ExpertFirstName")%></option>
<%
Else
%>
<option value='<%= RS.Fields("ExpertID")%>'><%= RS.Fields("ExpertLastName")%>,&nbsp;<%= RS.Fields("ExpertFirstName")%></option>
<%
End If
'Get Next Record
RS.MoveNext
Loop
End If
%>
</select>

<input type="button" class= "button" value="Reassign Case" onClick="verifyReassign('<%= RS.Fields("ExpertID")%>');">

---------------------------------

//JAVASCRIPT SECTION

function verifyReassign(ExpertID)
{
var answer = confirm("Are you sure you want to reassign this case?")

if (answer)
{
document.getElementById("cboExpertID").value = ExpertID;
alert("Case will be reassigned.")
frmResearch.submit();
}
else
{
alert("Case will not be reassigned.")
}
}

chazzy
11-08-2008, 07:33 AM
maybe you should start by showing us all of your code, not just bits and pieces.