K
Ken
Hello,
I have a webform that gets a record from SQL Server by using a stored
procedure.
The stored procedure uses 3 parameters in which after the record is found,
stored procedure #2 runs to update one of the columns called Status from
"incomplete" to "Pending"
Status is one of the parameters for stored procedure #1.
This all works fine, My problem is after the person is finished with the
record they then push the next button to get the next record.
Prior to gettting the next record I need it to execute stored procedure #3
to update the Status column from "Pending" to "Complete"
What it is doing is its getting the next record and then running stored
procedure #3 which causes the new record to be updated instead of the
previous.
Any help would be greatly appreciated!
CODE:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cn As New ADODB.Connection
Dim Rs As ADODB.Recordset
cn.Open("Driver=SQL
Server;Server=xxxxx;Database=xxxxx;uid=xxxxx;pwd=xxxxx;")
Rs = New ADODB.Recordset
Rs.Open("Exec MyRecords" & "'" & Session("valType") & "'" & ", '" &
Session("valTC") & "'" & ", '" & Session("valLang") & "'", cn)
Session("valSerial") = Rs.Fields("Serial").Value
Dim RsPending As ADODB.Recordset
RsPending = New ADODB.Recordset
RsPending.Open("Exec StatusPending " & "'" & Session("valSerial") &
"'", cn, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic)
lblSSN.Text = Rs.Fields("SSN").Value
lblBWE.Text = Rs.Fields("ProcDate").Value
lblDate.Text = Rs.Fields("ReceieveDate").Value
lblTime.Text = Rs.Fields("ProcessTime").Value
lblLang.Text = Rs.Fields("Language").Value
lblUser.Text = Rs.Fields("User").Value
End Sub
Private Sub btnNext_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNext.Click
Dim objConn As SqlConnection = New SqlConnection("Data
Source=xxxxxxx;UID=xxxxx;PWD=xxxxx;")
Dim objStatusCompleteCMD As SqlCommand = New
SqlCommand("StatusComplete", objConn)
objStatusCompleteCMD.CommandType = CommandType.StoredProcedure
Dim PSerialNo As SqlParameter =
objStatusCompleteCMD.Parameters.Add("@Serial", SqlDbType.Char, 12)
PSerialNo.Value = Session("valSerial")
objConn.Open()
Dim myStatusC As SqlDataReader =
objStatusCompleteCMD.ExecuteReader()
myStatusC.Read()
myStatusC.Close()
myStatusC = Nothing
objConnStatus.Close()
objConnStatus = Nothing
End Sub
I have a webform that gets a record from SQL Server by using a stored
procedure.
The stored procedure uses 3 parameters in which after the record is found,
stored procedure #2 runs to update one of the columns called Status from
"incomplete" to "Pending"
Status is one of the parameters for stored procedure #1.
This all works fine, My problem is after the person is finished with the
record they then push the next button to get the next record.
Prior to gettting the next record I need it to execute stored procedure #3
to update the Status column from "Pending" to "Complete"
What it is doing is its getting the next record and then running stored
procedure #3 which causes the new record to be updated instead of the
previous.
Any help would be greatly appreciated!
CODE:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cn As New ADODB.Connection
Dim Rs As ADODB.Recordset
cn.Open("Driver=SQL
Server;Server=xxxxx;Database=xxxxx;uid=xxxxx;pwd=xxxxx;")
Rs = New ADODB.Recordset
Rs.Open("Exec MyRecords" & "'" & Session("valType") & "'" & ", '" &
Session("valTC") & "'" & ", '" & Session("valLang") & "'", cn)
Session("valSerial") = Rs.Fields("Serial").Value
Dim RsPending As ADODB.Recordset
RsPending = New ADODB.Recordset
RsPending.Open("Exec StatusPending " & "'" & Session("valSerial") &
"'", cn, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic)
lblSSN.Text = Rs.Fields("SSN").Value
lblBWE.Text = Rs.Fields("ProcDate").Value
lblDate.Text = Rs.Fields("ReceieveDate").Value
lblTime.Text = Rs.Fields("ProcessTime").Value
lblLang.Text = Rs.Fields("Language").Value
lblUser.Text = Rs.Fields("User").Value
End Sub
Private Sub btnNext_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNext.Click
Dim objConn As SqlConnection = New SqlConnection("Data
Source=xxxxxxx;UID=xxxxx;PWD=xxxxx;")
Dim objStatusCompleteCMD As SqlCommand = New
SqlCommand("StatusComplete", objConn)
objStatusCompleteCMD.CommandType = CommandType.StoredProcedure
Dim PSerialNo As SqlParameter =
objStatusCompleteCMD.Parameters.Add("@Serial", SqlDbType.Char, 12)
PSerialNo.Value = Session("valSerial")
objConn.Open()
Dim myStatusC As SqlDataReader =
objStatusCompleteCMD.ExecuteReader()
myStatusC.Read()
myStatusC.Close()
myStatusC = Nothing
objConnStatus.Close()
objConnStatus = Nothing
End Sub