-
[RESOLVED] Bug !
cant seem to spot the bug! Can anyone please?
---------------------------------------------------
Using cmd1 As New SqlCommand(query, MyConn)
cmd1.CommandType = CommandType.StoredProcedure
..................
..................
cmd1.Parameters.Add("@ReturnErrorText", SqlDbType.NVarChar, (100))
cmd1.Parameters("@ReturnErrorText").Direction = ParameterDirection.Output
cmd1.Parameters.Add("@Success", SqlDbType.Int)
cmd1.Parameters("@Success").Direction = ParameterDirection.Output
MyConn.Open()
cmd1.ExecuteNonQuery()
cmd1.Parameters.Clear()
If Not CStr(cmd1.Parameters("@ReturnErrorText").Value) = String.Empty Then 'if there's error messages from stored proc
MessageBox.Show(CStr(cmd1.Parameters("@ReturnErrorText").Value))
MyConn.Close()
Exit Sub
End If
success = CInt(cmd1.Parameters("@Success").Value)
'before clearing the parameters swap the value of @success to see if Commit transaction is executed
cmd1.Parameters.Clear()
If success = 1 Then
MessageBox.Show("New School has been added SUCCESSFULLY.", " Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Using
-
Re: Bug !
As always, you should have told us which line the error occurred on, otherwise we can only guess.
I would assume that it is on the If statement just after this line:
cmd1.Parameters.Clear()
..and if so, the reason for the occurring is pretty easy to work out (just check the help for .Clear).
-
Re: Bug !
Ok si_the_geek,
Found the bug, a double clear parameters!
thanks
-
Re: Bug !
What does a "double clear parameters" mean?
-
Re: Bug !
Think it means she had
Code:
cmd1.Parameters.Clear()
placed twice in the code ;)